How to fix useRef: the value returned should be a valid value or reference in React | DevErrors