Munchstars is a web app aimed at children to educate them in a fun, interactive and engaging way about health and how decisions they make could affect their wellbeing.
age There is a need to reduce obesity in children by way of education so that they can make their own informed life choices. Published on the 20th May 2015 by Michelle Roberts http://www.bbc.co.uk/news/health-32797769
push forward with. Designers got full control over the UI decisions. Focusing on our personal goals that we wanted to achieve with our final project, our last chance with total creative freedom
data as state and when the state is updated the rendered markup will be re- rendered depending on the change. getInitialState() { return { users: {}, newUser: false, user: { name: this.props.player.name, nickname: this.props.player.nickname, points: this.props.player.points, avatar: { head: this.props.player.avatar.head, body: this.props.player.avatar.body, legs: this.props.player.avatar.legs, } }, } },
is the most popular router for React. It has a simple API with powerful features. const routes = ( <Router history={browserHistory}> <Route path='/' components={App}> <Route path='signup' component={SignUp} /> <Route path='login' component={LogIn} /> <Route path='game' component={Game} /> <Route path='wardrobe' component={Wardrobe} /> </Route> <Route path='/*' components={NoPage} /> </Router> );
apps state changes. This is the reducers job. A reducer is a pure function that takes the previous state, an action and returns the next state. function authReducer(state = initialState, action) { switch(action.type) { case 'LOG_IN': return Object.assign({}, state, { team: action.team, loggedIn: action.loggedIn }); case 'UPDATE_USERS': return Object.assign({}, state, { users: action.users }); default: return state; } }
All Reducers which we combined into the rootReducer. 2. An optional starting state - similar to React's getInitialState. const store = createStore(rootReducer, initialState);
data at the top level and passing it down, but you can connect() any component to make the actions and the store available to you anywhere. 1. Get state from store we want to pass down as props function mapStateToProps(state) { return { auth: state.auth, player: state.player, }; } 2. Bind actions to dispatch and make the actions available as props function mapDispatchToProps(dispatch) { return bindActionCreators(actions, dispatch); } 3. Create an <App/> component which passes the data to </Main> which makes the data available to the entire app const App = connect(mapStateToProps, mapDispatchToProps) (Main);
which means the date we bound to it is available to be passed down. The store is made available to it via the Provider component which is where we were able to pass the stores state to previously. import store, { history } from './store'; const routes = ( <Provider store={store}> <Router history={history}> <Route path='/' components={App}> <Route path='signup' component={SignUp} /> <Route path='login' component={LogIn} /> <Route path='game' component={Game} /> <Route path='wardrobe' component={Wardrobe} /> </Route> <Route path='/*' components={NoPage} /> </Router> </Provider> );