How to rerender when refs change
If you want to trigger a re-render after the ref changes, you must use useState instead of useRef. Only that way can you ensure that the component will re-render. E.g.: function Component() { const [ref, setRef] = useState(); return <div ref={newRef => setRef(newRef)} /> } As described under useRef documentation: Keep in mind that useRef … Read more