How to fix Ref passed to useImperativeHandle must be a valid ref object in React | DevErrors