Create a layout component in react
in this article we will learn how to create a layout component in react
we will create something like this
Header
Home / About / contact
Footer
Folder structure
In your src folder create three folders and create the folowwing files1 - components fol...
mandeephub.hashnode.dev1 min read
Saurav Pratap Singh
Developer
Inside the children you have kept /about, in react-router-dom when you keep / at the start of a path, you make it absolute and absolute paths cannot be used inside the children itself, right now it will work, but if for going to MainLayout the path was /main then to goto about page the path would need to be /main/about which will fail in your case, because you are placing an absolute path as a children, FIX: remove / from the children path and for Home, you can use index: true instead of assigning it a path, keep coding !