-
Notifications
You must be signed in to change notification settings - Fork 50.2k
Renamed createRef .value attribute to .current #12375
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
Conversation
|
Did we want to also ensure that the ref object is valid by checking if it has the |
trueadm
left a comment
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.
We should check for current, otherwise awesome!
|
Sounds like you're advocating some new functionality? Inside of |
|
Yes, we should warn here if the object doesn't have an own |
|
(This probably doesn't block the alpha but we need to add it to final release checklist. It should be a three line change though.) |
|
Sure, sure. I just wanted to clarify what was being suggested 👍 |
|
Okay. Added a DEV warning for this, plus a test. |
|
Docs note: ref={el => this.someRef.current = el}
ref={this.someRef = el}Idk if that is too much indirection. It could def cause some "could not access property 'current' of undefined" issues if not initialized. reactjs/react.dev@12d7c16#diff-5ff76597e6c547982df2b2e42f2f83c0R279 |
|
I don't see much value in showing an object wrapper for the callback ref example: this.textInput = { current: null }; // initial placeholder for the refMy vote for the callback example would just be to write to |
* Renamed createRef .value attribute to .current * Warn if invalid ref object is passed
* Renamed createRef .value attribute to .current * Warn if invalid ref object is passed
Based on team discussion about awkwardness of
inputRef.value.value.Docs have been updated as well, via 12d7c16.