fix: Null check added when resolving event's priority
Summary
I wanted to migrate from React 17 to React 18 and experienced issues with rendering when using new root API.
When window.event is null, Uncaught TypeError: Cannot read properties of null (reading 'type')error can be thrown when calling render function.
✅ Example with React 17 where nothing breaks and component is rendered correctly: https://jsfiddle.net/9zg3t4mc/1/
❌ Example with React 18 where error is thrown and component is not rendered: https://jsfiddle.net/92wtjb0g/
How did you test this change?
I run yarn build and then use React-prod.js inside fiddle that is throwing an error and with this change render is working now.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| react-compiler-playground | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Sep 27, 2024 4:08pm |
Hmm, the repro you provided is overriding a global to be null. I think that shouldn't ever happen in practice, though. Is there a legitimate case in some supported browser where the event can be null as opposed to undefined?
@josephsavona Thanks for quick answer. Yes, indeed it shouldn't be overwritten, but in real world I have experienced that client's app somehow is overriding this and I'm injecting a script into theirs app where I'm rendering react app and it will give me this error.
Fair. This seems reasonable to add, but we also need a regression test. Can you add on here?
@josephsavona I have added a test to cover this case. Cheers
This pull request has been automatically marked as stale. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize reviewing it yet. Your contribution is very much appreciated.
Closing this pull request after a prolonged period of inactivity. If this issue is still present in the latest release, please ask for this pull request to be reopened. Thank you!
Any news about merging this PR? I've experienced similar issues to what @classicdocs has described.
@josephsavona Can we reopen this PR ?