Skip to content

Instantly share code, notes, and snippets.

@davidgilbertson
Last active August 18, 2017 10:11
Show Gist options
  • Save davidgilbertson/b7c9b4a9f99e7fc301687e151540de6b to your computer and use it in GitHub Desktop.
Save davidgilbertson/b7c9b4a9f99e7fc301687e151540de6b to your computer and use it in GitHub Desktop.
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