Skip to content

Instantly share code, notes, and snippets.

@persianturtle
Last active February 11, 2018 21:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save persianturtle/b180f046f4414ca6abd967fcaac6c446 to your computer and use it in GitHub Desktop.
Save persianturtle/b180f046f4414ca6abd967fcaac6c446 to your computer and use it in GitHub Desktop.
[%bs.raw {|require('./app.css')|}];
type route =
| Home
| Page1
| Page2
| Page3;
type routeWithTitle = (route, string);
type user = {
name: string,
email: string
};
type nav = {isOpen: bool};
type action =
| Navigate(routeWithTitle)
| ToggleMenu(bool);
type state = {
routeWithTitle,
user,
nav
};
let component = ReasonReact.reducerComponent("App");
let make = _children => {
...component,
initialState: () => {
routeWithTitle: (Home, "Home"),
user: {
name: "Person Name",
email: "person@email.com"
},
nav: {
isOpen: false
}
},
reducer: (action, state) =>
switch action {
| Navigate(_routeWithTitle) => ReasonReact.NoUpdate
| ToggleMenu(isOpen) =>
ReasonReact.Update({
...state,
nav: {
isOpen: isOpen
}
})
},
render: _self => <div className="App" />
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment