Routes are some times better served as a modal. If you have a modal (like a login modal) that needs to be routeable and appear on all pages you may need to use query params. Will explore how to render a route all the time and use query params to control when it's content renders
Often times there is a route that is better served as a modal. You want to be able to link to it and still render the page behind it. With React Router this can be accomplished. We'll dive into rendering a route with a route that renders as a modal.
In this lesson we'll explore using Formik to create a form wizard. Each route will be a new piece of a form. We'll then use Prompt
and matchPath
to determine if we need to protect our data from being destroyed by navigating away from the page.
In this lesson we'll use the matchPath
function exported by react-router to find active nested routes inside of a parent component. This technique can be used for comparing routes outside of a React component, or even inside of life cycle methods to do data loading.
In this lesson we'll create a protected route just for logged in users. We'll combine a Route with a render prop and use a loggedIn prop to determine if the route should be allowed to be accessed. Finally we'll use nav state to preserve the location the user visited and redirect them back to the protected route once they login.
In this lesson we'll show how the Link component to
prop can receive an object. This allows us to pass state
to the route. With the nav state we destructure off of location we can determine if a user wants to open a modal or on a cold visit show an image embedded in the page.
In this lesson we'll show how to setup the Prompt component from React Router. We'll prompt with a static message, as well as a dynamic method with the message as a function. Finally we'll show that you can return true
from the message as a function to dynamically allow navigation.
In this lesson we'll use the match.path
value passed in by React Router to setup dynamic routes for Tabs. This will allow us to setup dynamic tabs which can be navigated to based upon the URL. With this pattern we can change the base path and our tab routes will automatically match and render correctly.