'Router helpers for react router

I am very used to rails that generates helpers for my routes. For instance, user_path(user) would return the path to the user.

This has multiple advantages; most importantly that I'll get an error if I make a typo or when I refactor.

I would like the same functionality in react router - that is: Given a router with multiple routes (possible) nested, generate url helpers.

If that is not the case, what are the alternatives (besides using the raw urls - e.g. /user/15)?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source