February 2019
Beginner to intermediate
180 pages
4h 4m
English
In Index.re, let's wrap <App /> within a router component that provides the currentRoute prop:
ReactDOMRe.renderToElementWithId( <Router.WithRouter> ...((~currentRoute) => <App currentRoute />) </Router.WithRouter>, "root",);
In Router.re, we define three components—<WithRouter />, <Link />, and <NavLink />—using the module syntax. Since each file is also a module, those three components are nested under the Router module, and in Index.re we need to tell the compiler to look for <WithRouter /> within the Router module:
module WithRouter = { type state = route; type action = | ChangeRoute(route); let component = ReasonReact.reducerComponent("WithRouter"); let make = children => { ...component, didMount: self => { let watcherID ...Read now
Unlock full access