-
-
Save dhruvdutt/4605f08fb22d3db0a260351c3d60a8e0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import HomePage from './HomePage.jsx'; | |
import AboutPage from './AboutPage.jsx'; | |
import UserPage from './UserPage.jsx'; | |
import FourOhFourPage from './FourOhFourPage.jsx'; | |
const PAGES = { | |
home: HomePage, | |
about: AboutPage, | |
user: UserPage, | |
}; | |
const Page = (props) => { | |
const Handler = PAGES[props.page] || FourOhFourPage; | |
return <Handler {...props} /> | |
}; | |
Page.propTypes = { | |
page: PropTypes.oneOf(Object.keys(PAGES)).isRequired, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment