This is a solution to the Entertainment web app challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic project.
Users should be able to:
- View the optimal layout for the app depending on their device's screen size
- See hover states for all interactive elements on the page
- Navigate between Home, Movies, TV Series, and Bookmarked Shows pages
- Add/Remove bookmarks from all movies and TV series
- Search for relevant shows on all pages
- Live Site URL: [(https://dazzling-moonbeam-3025e2.netlify.app/)
- Semantic HTML5 markup
- CSS custom properties
- Flexbox
- CSS Grid
- React
- React-router dom for routing
- Custom react hooks
I needed a reuseable function that sets State in different components so I learned to use custom hooks.
import { useState } from 'react';
export const useSearch = (movieData) => {
const [searchQuery, setSearchQuery] = useState('');
const [searchResult, setSearchResult] = useState([]);
const searchHandler = (e) => {
const typedInput = e.target.value;
// updates the input
setSearchQuery(typedInput);
// do the logic
const query = typedInput.trim().toLowerCase();
const searchResults = movieData?.filter((movie) =>
movie.title.toLowerCase().includes(query)
);
setSearchResult(searchResults);
};
return { searchResult, searchQuery, searchHandler };
};
};- Twitter - @chessncode
