profile
viewpoint

Ask questionsRefs - "object is not extensible"

I wanted to drop my string-based refs bindings and replace them with callback-based ones, however, when I tried to replace ref="email" with ref={ (ref) => this.refs.email = ref }, I received an error: TypeError: Can't add property email, object is not extensible.

I didn't find any informations about this in docs, but I found other issue in which @frederickfogerty did what I tried to do: ref={ c => this.refs['wrapper'] = c }

... and I assume that back in 22 Sep 2015 it worked, now it doesn't. Did something change and refs object became nonextensible? Is assigning refs manually through callbacks to this.refs considered a bad practice now?

facebook/react

Answer questions vishwa3

@vishwa3 you need to use this.query.current.value, not this.query.value

@satya164 :Thanks

useful!

Related questions

Disable react strict mode on third party libraries hot 6
Warning: Unknown DOM property for. Did you mean htmlFor?
React@16.9 block `javascript:void(0);`
TypeError: Object(...) is not a function hot 4
Warning: validateDOMNesting(...): <tr> cannot appear as a child of <table> hot 3
[ESLint] Feedback for 'exhaustive-deps' lint rule hot 3
React custom hook "Should have a queue. This is likely a bug in React" error message. hot 2
useEffect causes 'callback is not a function' exception hot 2
DevTools: Updating state or props in devtools does not trigger component update. hot 2
Infinite loop in useEffect using blank object or array hot 2
False-positive security precaution warning (`javascript:` URLs) hot 2
"DevTools v4 is incompatible with this version of React" with React Native & latest version of React hot 2
Hooks API - hook breaks when exported from module hot 2
Function components do not support contextType. hot 2
Feedback on useEffect depndencies change error hot 2
Github User Rank List