-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Context being hijacked by second instance of application #1998
Comments
Hey, You mean that the second applications context value is copied over to the first one? Which should not have such an effect, it's pretty hard to put a label on it atm. EDIT: all changes for anyone wondering 10.0.0-rc.3...10.0.0 |
@JoviDeCroock Yes that is exactly what seems to be happening. The weird thing is the I will keep looking to see if I can reproduce it. I am not seeing anything wrong in the app at the moment (which does not mean that there isn't something) and changing back in forth just in the Preact version without any other code changes toggles between expected and broken function. I will also look if copying the old code of the change above in solves it with |
It is kind off odd that dispatch would be equal in that case since that is only set once https://github.com/preactjs/preact/blob/master/hooks/src/index.js#L80 |
@JoviDeCroock Thanks for the feedback. After much trying I finally got to a minimal repo reproducing this issue. https://github.com/AlmeroSteyn/preact-context-hijack It seems that if I share a state variable from The above repo uses When you run the app with You should see two inputs with text next to them. Top one says Both inputs are separate Preact apps, bootstrapped and rendered into a specific element in the DOM. When you start typing in the top input you will see that the text changes from This only seems to happen when the I hope that this gives enough info to trace the issue. It really does look as this is happening in Preact itself. If you downgrade the Preact version to |
I am facing a problem in a current application we are building with Preact.
Firstly I have not been able to reproduce the issue in a small repo with one Preact app so I want to state it first to hear if anyone has any ideas.
Issue description
I have created a chat window web application that should be able to start on any web page by rendering the Preact application in a specific element.
This Preact application relies heavily on
Context
as well as theuseContext
hook.The application is written purely in Hooks and function components.
There may more more than one chat window on a page, so this means starting more than one Preact application, each targeting another element.
In
v10.0.0-rc3
everything works as expected.However if I upgrade the to
v10.0.0
launching a second application and rendering theuseContext
consumers seems to override theContext
values provided by theContext.Provider
in the first application.After that the
useContext
hooks in the first application gets theContext
values provided by the second application only.If I revert to
v10.0.0-rc3
again the two applications once again function properly as separate entities.Are there any changes between
10.0.0-rc3
and10.0.0
that could have triggered the issue I am seeing?I will continue trying to reproduce the issue in a small repo, but any ideas while I am doing that would be extremely helpful as I have re reverse engineer quite a large app to find the exact point of failure.
The text was updated successfully, but these errors were encountered: