I want to add the searchContext
context in my App.js so that my Navbar
an Results
components have access to the variables in it. How would I do this with my routes set up? I tried to just add with with them but that didn’t work. This is the code.
JavaScript
x
13
13
1
<Router>
2
// Where does <searchContext.Provider> go?
3
<Navbar></Navbar>
4
<Routes>
5
<Route exact path='/' element={<Home />} />
6
<Route path='/results'>
7
<Route path='/results/:value' element={<Results />} />
8
{/*<Route path='/results/:value/:slot' element={<Slot />}*/}
9
</Route>
10
// Another route that has nothing to do with searchContext
11
</Routes>
12
</Router>
13
Edit: Added “// Another route that has nothing to do with searchContext”
Advertisement
Answer
if i were you i would just wrap the all thing with the provider as long as its not to heavy.