What are the differences between useRef and createRef?
The difference is that createRef will always create a new ref and useRef returns the same ref upon every render.
So technically we can do the differences like below:
createRef | useRef |
---|---|
createRef will always create a new ref | useRef returns the same ref upon every render |
React.createRef() is a factory returning a ref { current: null } | React.useRef(initValue) also returns a ref { current: initValue } |