-
Notifications
You must be signed in to change notification settings - Fork 46.8k
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: Null check added when resolving event's priority #31044
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
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? |
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.
Requesting changes for a regression test
@josephsavona I have added a test to cover this case. Cheers |
Summary
I wanted to migrate from React 17 to React 18 and experienced issues with rendering when using new root API.
When
window.event
isnull
,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 useReact-prod.js
inside fiddle that is throwing an error and with this change render is working now.