Answer the question
In order to leave comments, you need to log in
How to change block location in mobile devices?
I am writing in react. There is a block that is located in a different place in mobile devices, is there a way to dynamically change the location of the block? I can append through queryslector etc, but it's inconvenient to write them all the time. Maybe there is a library?
Answer the question
In order to leave comments, you need to log in
First you need to find out the width of the screen.
const [screenW, setScreenW] = useState(undefined);
useEffect(() => {
setScreenW(window.innerWidth);
}, []);
const Component = () => {
...
return (
...
{screenW >= 1024 && <BigScreenComponent />}
<SomeOtherComponent />
{screenW < 1024 && <SmallScreenComponent />}
...
);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question