I have made a Navigation bar in react which had two components one for mobile navigation and one for desktop navigation, and I m conditionally rendering both according to the width of the device. But for some reason, it's not working on IOS, but working on other android devices properly.
here is the code.
const Navbar = () => {
const [isMobile, setIsMobile] = useState(
window.matchMedia("(max-width:1024px").matches
);
useEffect(() => {
window.addEventListener("resize", () => {
setIsMobile(window.matchMedia("(max-width:1024px").matches);
});
});
return <div>{isMobile ? <Mobnav /> : <DesktopNavbar />}</div>;
};
and here is the iPhone image of the website :
I did have added the meta tag :
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />