-
Notifications
You must be signed in to change notification settings - Fork 36
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
fix: change to use __reactEventHandlersXXX to get latest event handler #12
fix: change to use __reactEventHandlersXXX to get latest event handler #12
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can confirm that fix works.
@newying61 can you solve the conflicts, then i would merge your PR. |
…iately, change to use __reactEventHandlers to trigger the latest event handler
80a5a5c
to
993e08d
Compare
@chgohlke Resolved. Thanks for the review. |
@newying61 you mentioned events working with React 16.8.2. I am using 16.13.1 and try to not use this package but it was not working :( Are you sure it is working for you? ReactDOM.render(
<InjectApp store={configureStore(initialState)} />,
omniContainer.shadowRoot,
) |
@gilles-yvetot It's working in my test app with latest react version 16.13.1
The app looks like:
Is the event not working? In React-DOM 16.13.1, the attaching event listener code is not changed. |
@newying61 sorry I am only replying now. I tried your solution on my project but could not make it work. Then tried again on a small project and it worked. So after some debugging time, I found out that my issue was caused by a portal within the shadow dom. Outside of that, your tip helped so much. Thanks again! |
Hi @gilles-yvetot , no problem. And some other interesting finds:
So, if you know what events will be triggered in Portal inside shadowRoot, you can attach the event handler first in the main app, like |
Hi @gilles-yvetot |
@newying61 even if your package become obsolete, thanks for the help you gave me here and to the community with this package |
Found an issue when using useState hook (React 16.8.2).
The event handler inside memoizedProps is not updated synchronously, as a result, it's using an old scope which is using the old state value.
Change to use the handlers in __reactEventHandlers from React.js ver 16.0.0, which seems to be updated every time.
Will do more test later.
Raise a pull request first, in case any one has the same issue.
Other findings:
If render react app to this.shadowRoot, we don't need to use this package.
Events are working in React 16.8.2.
But if adding a div to this.shadowRoot and render react app into it, still need this package to retarget react events.