Denys Medvediev
Denys Medvediev

Reputation: 1260

Nested routes in react-router-4

I have online version of my small learning app here

Quick overview: Here I have three components

I'm trying to show detailed info about selected user with url like this users/user-name . Detailed info should be on the same page. But I'm doing somthing wrong, if somebody can help me with it and I update my code I will appreciate it, thanks!

Note: I was trying to implement example from react-router documentation

Upvotes: 0

Views: 44

Answers (1)

dMcNavish
dMcNavish

Reputation: 647

You are not rendering the UserDetail component anywhere. You can do this my changing the Child component to the following:

<div>
  <h3>ID: {match.params.name}</h3>
  <UserDetail />
</div>

This will render the UserDetail component, but that component does not have access to the users list you created in the UserList class. The recommended way to share data between components is to use either Redux or Flux. This will allow you to load components independently of each other and have them access the same data.

Upvotes: 1

Related Questions