In my current project I have a <Header />
component that I would only like to render when the user is viewing the pages at "/library" or "/admin". I find myself somewhat perplexed though because I am following the example set about in the docs, here but I am getting an error in the console when I do so.
My Route is written as follows:
<Route
path={['/admin', '/library']}
render={props => (
<Header {...props} />
)}
/>
This works, the <Header />
component will only render when it matches those paths but I'm still seeing the following error in the console:
Warning: Failed prop type: Invalid prop
path
of typearray
supplied toRoute
, expectedstring
.
Given that I'm matching the example in the documentation, I'm surprised that I'm getting the above error. Is there something I'm not understanding correctly? This is the main part of what I find so perplexing and it makes me wonder whether I am doing something wrong, especially since in spite of the error message my code works as expected.
I am using React v16.6 and react-router-dom v4.3.1.