history
object to programmatically navigate to other routesLink
and NavLink
and when to use which to navigate declaratively between routesStarting Sandbox - https://codesandbox.io/s/trinkets-react-router-ii-starter-wcr2m Solution sandbox - https://codesandbox.io/s/trinkets-react-router-ii-solution-e1g2k
ItemList
and Item
components. Note that they are both importing data from a js file. Normally we want to get data from an API, so we won't be able to import it like this. Instead, we will receive data via props from App
.Route
. This is where the render
props comes in handy!Set up useState:
We want to add our data from data.js to the useState hook. We are setting it up like this to pass our data down to our other components.
const [product] = useState(data);
component
prop. Add a render prop.<ItemList />
<ItemList items={product} />