With the version 1.0 release of react-router, the named Route feature was dropped. In earlier versions, you were able to define each Route with a name parameter:
and link to the RouteHandler via:
This provided a way to avoid hard-coding URL patterns throughout application code. Starting with version 1.0, the named paths are not allowed. The to parameter only accepts a path; it isn’t as convenient to keep the code DRY. A solution is to use the crossing library, whose purpose is to resolve names or URL patterns from an object that you provide.
Here is what an example react-router-based application could look like that shows the use of crossing to keep URL patterns DRY. You can get a copy of the repository and run it yourself from https://github.com/lincolnloop/crossing-react-router-demo.
About the author
Brian Luft
A Full-Stack developer by virtue of 15 years working with various types of companies and technologies; which is another way of saying he has no special skills. With a little sister unwilling to play D&D, he …