Merged
Conversation
koesie10
approved these changes
Feb 8, 2024
Member
koesie10
left a comment
There was a problem hiding this comment.
Thanks, LGTM!
Leaving the initial value empty was leading to a computed type of
Thing | undefinedand that was causing problems when trying to pass it toref={ref}on an element. The ref type already expectsnullto be a possible value, so using that instead ofundefinedmakes everything happy.
It seems like the behavior of passing in null is slightly different than specifying the type as T | null since the first doesn't allow you to directly modify the ref. However, we don't need that, so this seems like it works for better for us.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Everywhere we create or consume a React ref, give it a proper type instead of using
Ref<any>.To make this work I switched to passing
nullas the initial value instead of leaving it blank. I believe this doesn't change the behaviour of the components in any way.Leaving the initial value empty was leading to a computed type of
Thing | undefinedand that was causing problems when trying to pass it toref={ref}on an element. The ref type already expectsnullto be a possible value, so using that instead ofundefinedmakes everything happy.Checklist
ready-for-doc-reviewlabel there.