I have been working on my React app and experimenting with how to dynamically display input elements based on different screen sizes. To achieve this, I implemented the use of window.innerWidth
as shown in the code snippet below:
<div className='Trends'>
<div>
<h4 className='trend-head'>TRENDING ITEMS</h4>
</div>
{window.innerWidth < 991 ? (
<div className='input-arrow'>
<input type="text" placeholder={selectCategory || 'All'} className='trend-input' />
<BiSolidDownArrow className='dr-arrow' onClick={() => setShowArray(!showArray)} />
</div>
) : (
<div className='Array-div'>
<ul>
{storedArray}
</ul>
</div>
)}
</div>
);
Despite implementing this logic, it seems that the input div is not being displayed correctly. Upon inspecting my browser's console, I noticed that the input div is missing when compared to other div elements on the page.