import React, { useState } from 'react' import ProfileModal from 'components/Modals/ProfileModal/ProfileModal' import { useHistory } from 'react-router-dom' import Layout from 'hoc/Layout' import SearchContent from './SearchContent/SearchContent' import { Home, Movies, Tv, LatestVideo, List } from './routes' /** * Remember: the component where you want to use the context is the one which you wrap * with the provider. */ const Browse = props => { // Render different videoSections based on this route prop const { route } = props const initialState = localStorage.getItem('profileSelected') ? false : true const [modal, setModal] = useState(initialState) const history = useHistory() const profileClickHandler = () => { setModal(false) localStorage.setItem('profileSelected', true) } let browseContent if (route === '/browse') { browseContent = } else if (route === '/browse/movies') { browseContent = } else if (route === '/browse/tv') { browseContent = } else if (route === '/browse/latest') { browseContent = } else if(route === '/browse/list') { browseContent = } else if (route === '/search') { browseContent = } return ( <> {!modal && {browseContent} } ) } /** * Remember the thing which gave you trouble here. Never mutate state directly. Since I didn't create * a copy of the trending state array, I kept splicing each item all over the place, which * caused unnecessary problems. */ export default Browse