Created
March 17, 2018 12:54
-
-
Save solidfox/a34548d458e691f64c685a4d6e956592 to your computer and use it in GitHub Desktop.
Component with closure of state and dispatch will make React replace everyting inside AppBody on every re-render.
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
function AppComponent({state, dispatch}) { | |
// Component with closure of state and dispatch will make React replace everyting | |
// inside AppBody on every re-render. | |
function AppBody() { | |
switch (state.get('page')) { | |
case "dish-details": | |
return <DishDetails key='dishDetails' | |
dish={core.getBestInformationOnSelectedDish(state)} | |
nGuests={state.get("nGuests")} | |
dispatch={dispatch}/> | |
case "dinner-overview": | |
return <DinnerOverview nGuests={state.get('nGuests')} | |
menu={core.getMenuDishes(state)} | |
dispatch={dispatch}/>; | |
case "print-dinner": | |
return <PrintDinner nGuests={state.get('nGuests')} | |
menu={core.getMenuDishes(state)} | |
dispatch={dispatch}/>; | |
default: | |
return <WelcomeView dispatch={dispatch}/>; | |
} | |
} | |
return [ | |
<header key="header"> | |
<h1>Dinner Planner</h1> | |
</header>, | |
<AppBody key="body"/>, | |
<footer key="footer">Lab Group 5 - Daniel Schlaug & Siddhant Gupta</footer> | |
]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment