课程: Learning Full-Stack JavaScript Development: MongoDB, Node, and React

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Displaying a different root component

Displaying a different root component

- [Narrator] When we navigate to a contest we'll need to know which contest are we navigating to and we can simply do that by making this function receive the contest ID to navigate to. And in the contest preview, when we do the own click which is the alias for that navigate to contest function we can pass in the contest.id here to that function. So this contest.id will make it all the way to app component and be represented here as contest id. And we can log that in here to test. Refresh. Click on this contest and we get the contest id. So let's create a component to represent a contest. So we can name it contest and let's pass it the ID for the contest that we want it to display. The ID is here in Navigate Contest. And to make this page content able to access that we would also need to put it on the state somewhere. We can make this page variable an object instead of a scaler value and have it include other…

内容