Follow me on Twitter @theisomorphic
Learn about react-router-dom's
-
BrowserRouter -
Route -
Link -
Switch -
locationobject
- Add
react-router-domas dependency - Set up
BrowserRouter - Add first two
Route's and build out corresponding components to render. - Add
NavBarcomponent. - Build out 404 Error component and try to figure out a
pathfor theRoute - Add
Switchcomponent to the application. - Improve UX of 404 Error page.
- Learn about the
renderprop pattern to add more control of whatRouteis rendering. - Learn about the
.pushmethod on thehistoryobject.
- Refactor
Addcomponent to include aformto add new ideas. - Build out a helper function to handle
formsubmissions. - Pass the API method -
handleAddIdeato theAddcomponent using therenderprop, and invoke it inside theform'sonSubmithandler. - Use the
history.pushmethod to push the user home after submitting an idea. - Refactor the
Homecomponent to show the ideas as an ordered list ofLinkcomponents that take the user to the idea's voting page. - Add a ternary expression to render the
ideasif theideas.length > 0otherwise, display a nice message - "Looks like there are no ideas!"
- Learn about how to add URL parameters.
- Learn about the
matchobject.
- Add a new
Routeto catch the/ideas/<unique-id>. - Build out the
Votecomponent to be rendered at/ideas/<unique-id>. - Use the
getIdeaandhandleVoteAPI methods to render the idea'slikesandtitledata, and add thebuttonclick behavior, respectively. - Add a conditional to handle ideas
id's that are not in our backend.
- Learn about the
NavLinkcomponent.
- Add
activeStyleto the navigation links so that when clicked the styling of the link changes accordingly. - Add emojis next to the like number depending on the like count. For example, if the like count is less than 0 we display a 💩, equal to zero - ⭐️, and greater than zero - 🌶.
- Learn about Higher Order Components
- Learn about the
Redirectcomponent - Learn about how to pass state into
Redirect.
- Add a
Logincomponent that will render aformwith a dropdown menu of usernames. - Invoke the
auth.setAuthUserAPI method inside theform'sonSubmithandler function. - Add the
auth.unsetAuthUserAPI method as theonClickhandler on the logout button. Additionally, show theauthUsername somewhere in theNavBar. - Build a Higher Order Component called
PrivateRoutethat invokes therendercallback if the user is authenticated otherwise, return aRedirectcomponent to take the user to the login page. - Add the
authUserto the second argument ofhandleAddIdeainside of theAddcomponent'sonSubmithandler. Display theauthorinside of theVotecomponent. - Pass referrer state into the
Redirectcomponent rendered byPrivateRouteso that after logging into the application the user is redirected to the originally requested page instead of/.