React Router 4

I want to share about the router library: React Router. At this time I write this post, the most popular react router library: React-Router latest release is on version 4 beta 7. Its totally rewrite from previous version, version 3, which I used.

Server Rendering

On version 3. there is match function to match routes to current request-location. So if yout want to use react-router for server side, you have to do following:

In version 4, its way more easier, you just need to use StaticRouter:

By the way, I create simple repo for trying this: https://github.com/egig/ReactRouter4-Isomorphic-Example

Route Matching

It is now suports what path-to-regex supports: https://github.com/pillarjs/path-to-regexp. Big resolution for this issue: https://github.com/ReactTraining/react-router/issues/391.

Discussion