I'm trying to reuse my MainSection component for two different purposes (single story and all stories). To effect this, I want to pass in a property, home, in the Routes that go to those renderings of that component. Home is true or false, and I want to render the MainSection component based on that boolean. However, I home keeps being undefined when MainSection gets rendered. The link and route are updating the URL, but not rendering with the props I want. Am I doing something wrong?
Here are my routes:
function Routes(){
return(
<Switch>
<Route path="/" element={<MainSection home={true} />} />
<Route path="/story" element={ <MainSection home={false} />} />
</Switch>
)
}
and here is the code for my MainSection component:
function MainSection({ home }){
console.log(home)
return(
<div className="main-section">
<BigPicture home={ home }/>
<Quotes home={ home }/>
</div>
)
}
The console log keeps returning undefined.
Thanks!