mercredi 1 novembre 2017

React BrowserRouter - how to programmatically navigate to different routes?

I currently have this in my app.js file:

<BrowserRouter>
<div>
    <Switch>
        <Route exact path="/" component={CompOne}/>
        <Route path="/two" component={CompTwo} />
    </Switch>
</div>
</BrowserRouter>

In my CompOne, I want to programmatically navigate to CompTwo. I know I can use window.location to navigate to the /two path, but I would like to pass in some props to CompTwo.

How would I go about programmatically navigating from CompOne to CompTwo while passing in props?




Aucun commentaire:

Enregistrer un commentaire