-
Notifications
You must be signed in to change notification settings - Fork 67
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
FED-1910 Fix react_dom API typings, add tests #382
Conversation
Security InsightsNo security relevant content was detected by automated scans. Action Items
Questions or Comments? Reach out on Slack: #support-infosec. |
5b6e052
to
886fb2e
Compare
886fb2e
to
d61e63f
Compare
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.
+1
Love the new test coverage!
@Workiva/release-management-p |
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.
+1 from RM
Motivation
The existing nullability/typings for
ReactDom.findDomNode
andReactDom.render
exported frompackage:react/react_client/react_interop.dart
are incorrect.findDOMNode
returns null in many cases, but its return type is incorrectly non-nullable.render
returns null for some cases (function components,null
),Element
for DOM components, andCharacterData
for strings and numbers, but is incorrectly typed as non-nullableReactComponent
. Thecomponent
argument also acceptsnull
and other "ReactNode" arguments to rendered, but its type is incorrectly non-nullable and restricted to justReactElement
.These bad typings cause runtime errors in some cases. Unfortunately, there wasn't good test coverage around these methods.
These typings also only affect these APIs under the
ReactDom
class in package:react/react_client/react_interop.dart, and not the top-levelFunction
-typedfindDOMNode
andrender
APIs exported frompackage:react/react_dom.dart
, which most consumers use.Because these typings were incorrect and will lead to runtime errors in some cases, and the changes have a low likelihood of causing breakages, it feels appropriate to release these changes as a patch.
Solution