I want to test if my component can get search part of location and transform to json for use, but when I set initialEntries
with the querystring the search part is not changed.
//My Test
render(
<MemoryRouter inititalEntries={['/pesquisa?number=1&uf=PR']}>
<App/>
</MemoryRouter>
)
//My Component
const Pesquisa = (props) => {
const { search } = props.location
// what i want
// search === '?number=1&uf=PR'
// what i have
// search === ''
}
export default withRouter(Pesquisa)
// My Container App
const App = () =>
<div className="App">
<BrowserRouter>
<Switch>
<Route path="/pesquisa" render={props => <Pesquisa/>}/>
</Switch>
</BrowserRouter>
</div>
Aucun commentaire:
Enregistrer un commentaire