Use the useRef hook. The value stored by the reference will not be reinitialized during a re-render. Changing the value stored by the reference will not trigger a re-render, as it is not a state change.
CLICK HERE to find out more related problems solutions.