As I see in your question, you are using Link for navigation. Given that you also want to send data using Link, you can pass an object to it instead of a string path , as specified in the React-router docs . Thus, you can pass the displayed information using the state object to TableRow , for example,
const {name, time, episodeId, img} = this.props; <Link to={{pathname:showUrl, state: {show: {name, time, episodeId, img }}}}>{this.props.name}</Link>
Now you can get this information in the Show component as
this.props.location.state && this.props.location.state.name
Another thing you need to take care of is that you need to pass the details into the rendering function
<Switch> <Route exact path="/" render={(props) => { return <Table shows={this.state.shows} {...props}/>; }} /> <Route path="/show/:showID" render={(props) => { return <Show {...props}/>; }} /> <Route component={FourOhFour} /> </Switch>
Now the above solution will only work if you are moving from the application, but if you change the URL, it will not work, if you want to make it more reliable, you will need to pass data to the show component and then optimize the life cycle functions
You would. do it like
<Switch> <Route exact path="/" render={(props) => { return <Table shows={this.state.shows} {...props}/>; }} /> <Route path="/show/:showID" render={(props) => { return <Show shows={this.state.shows} {...props}/>; }} /> <Route component={FourOhFour} /> </Switch>
And then in the Show component
class Show extends React.Component { componentDidMount() { const {shows, match} = this.props; const {params} = match;
However, libraries like redux and reselect . with Redux, your shows data will be in the same shared repository, and you can access it in any component, and reselect gives you the opportunity to create a selector that will be saved to get the corresponding Show data from shows , so the same calculation is not repeated again . Please study them and see if they are suitable for your project.