I've created a ShowcaseMovie component that fetches data using componentDidMount()
, stores it in state, and renders Card components to display the data. The component also features four button elements for toggling between different filters: upcoming
, top_rated
, popular
, and now_playing
. Each button triggers an onClick event that calls the changeFilter
function to update the currentFilter
state based on the selected key.
One issue I've encountered is that clicking on the filter buttons sometimes causes the page to scroll to the top unexpectedly. I've tried troubleshooting this behavior but haven't been able to pinpoint the exact cause. Any insights or suggestions would be greatly appreciated.
Update: It appears that the scrolling issue arises when there's no fixed height set for an element containing dynamic children. Setting a specific height value, such as height: 200vh
, seems to resolve the problem temporarily.
While I believe I have addressed the issue, I'm open to hearing other perspectives on why this behavior occurs and alternative solutions to address it. Setting a minimum height with min-height
could be a workaround, but I'm interested in exploring more robust fixes.
ShowcaseMovie.js
(Component code omitted for brevity)
ShowcaseMovie.css
(CSS styles omitted for brevity)
Card.js
(Component code and CSS styles omitted for brevity)
utilities.js
(Utility functions omitted for brevity)