I suspect you'd be much better off with a useEffect built around Window.matchMedia than something using innerWidth. This is the JavaScript equivalent of css media queries. That way you're using something event-driven.
Something like this maybe:
const [ navOpen, setNavOpen ] = useState(true)
useEffect(() => {
const x = window.matchMedia("(max-width: 700px)")
function myFunction(e) {
setNavOpen(false);
};
x.addListener(myFunction)
return () => x.removeListener(myFunction);
}, []);
Note: since it's got an event listener, note there is a clean up function being returned to remove the listener.
credit: I copied part of my code from w3schools
Edit: adding empty dependency array on recommendation of @agus-zubiaga