Routing in ReasonReact and What to Expect

reasonreact

#1

@thangngoc89 graciously provided his routing example, and between his example and the docs, I am still left scratching my head and a bit frustrated as my own routing implementation is not compiling.

I wanted to use and get familiar with the Routing thats provided within ReasonReact, but I am wondering if I should just use bs-director or some bindings made for React Router. Have you had a better experience than I with routing in ReasonReact? Can you share your example?

Also, how should we expect the Router in ReasonReact to change? I have heard on discord something about context 2 ?

Much Thanks. <3


#2

Here’s the entire implementation of ReasonReact router: https://github.com/reasonml/reason-react/blob/eafe22ae03060ed339e144149d886e62b6a4e167/src/ReasonReact.re#L946

Start with ReasonReact router. It’s thinner than even bs-director. I’d advice just using it rather than skipping it and then trying to wrap it. The official docs are the source of truth; anything else good will be upstreamed hopefully.

We will try the context v2 API too, but as always, there will be an upgrade path.


#3

The content of WithRouter module should be what you need to focus on. I built wrapper/abstraction because I want to be future proof.