Currently, I am working on making my design responsive. My approach involves displaying a basket when the div style is set to "block", and hiding it when the user browses on a mobile device by setting the display to "none". The user can then click on a button to open the basket.
The issue I am facing now is that the default state is set to true. This means that when a mobile user visits the website, they will see the basket first, which is not desirable. Ideally, I want the basket to be hidden when the user first visits, and they should need to click on a button to reveal it. However, setting the default state to false is not an option as desktop users won't be able to see the basket then.
// MY STATE
const [toggle, setToggle] = useState(true);
<button onClick={() => setToggle(!toggle)}>Open</button>
<div
className="box_order mobile_fixed"
style={{ display: `${toggle ? "block" : "none"}` }}
>
// BASKET CODE
</div>