Last active
February 11, 2018 21:07
-
-
Save persianturtle/b180f046f4414ca6abd967fcaac6c446 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
[%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: "[email protected]" | |
}, | |
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