Im trying to make my website change view from mobile to desktop view using a button in javascript
const handleClick = () => {
const viewport = document.querySelector("meta[name=viewport]")
viewport.setAttribute(
"content",
"width=200px, initial-scale=1.0, maximum-scale=2.0, user-scalable=0",
)
}
I am using this code and it changes the viewport in html when I inspect using chrome but the screen is not changing
I guess, you cant use document.queryselector directly in react js like we do in html, instead you have to use useRef and ref for accessing DOM elements.