Renamed createRef .value attribute to .current#12375
Renamed createRef .value attribute to .current#12375bvaughn merged 2 commits intofacebook:masterfrom
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.
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.