May 2019
Intermediate to advanced
496 pages
10h 38m
English
The other routes in App aren't so simple. They require the use of state and props. For example, here's how we rendered AppointmentFormLoader before, which needs to be passed a customer object and an onSave handler:
switch(view) { case 'addAppointment': return <AppointmentFormLoader customer={customer} onSave={transitionToDayView} />;
To do the same with React Router, we need to use the render prop on a Route:
<Route path="/addAppointment" render={() => ( <AppointmentFormLoader customer={customer} onSave={transitionToDayView} /> )}/>
This render prop poses a problem. How can we verify that the AppointmentFormLoader was passed the right props?
We need to invoke the render function, but ...
Read now
Unlock full access