Using UseRef Or CreateRef
I want to set the const [solution, setSolution] = useState(0); with the value of a input element by pressing a button I get the same result using createRef or using the useRef hoo
Solution 1:
createRef
is for class components, calling it in a context of function component will be treated as a normal function, hence will RE-INITIAL your reference on every render.
useRef
is for function components, you lose your ref on unmount lifecycle.
Post a Comment for "Using UseRef Or CreateRef"