React routing

We have to use routing in client-side applications. For ReactJS we also need another routing library, so I recommend you use react-router, which is provided by the React community.

The advantages of React routing are:

  • Viewing declarations in a standardized structure helps us to instantly identify our app views
  • Lazy code loading
  • Using react-router, we can easily handle the nested views and their progressive resolution of views
  • Using the browsing history feature, a user can navigate backwards/forwards and restore the state of the view
  • Dynamic route matching
  • CSS transitions on views when navigating
  • Standardized app structure and behavior, useful when working in a team

Note

The React router doesn't provide any way to handle data fetching. We need ...

Get Learning Web Development with React and Bootstrap now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.