I am working on a web application that can load one of several scenarios based on a selection that a user makes.
A webpage has already been implemented to load a scenario, which is initiated by making an API call to the back end (python via flask).
The web-based UI is in javascript making use of react js.
At the moment I use the Router Switch method to allow navigation between a few web pages.
What I would like to achieve is:
- On Home page, user selects scenario and presses Load
- Load in fact calls a
renderRedirect()
function, and triggers navigation to the Scenario page. - Upon arrival on the Scenario page, the API call to the back-end is made requesting the creation of the specific scenario that the user had selected in step 1.
What I don't know is how to get the information (just a string scenario_id
) from the Home page to the Scenario page.
I found this question/answer, but to implement it I would have to rework my current Switch
setup to instead make use of router.push
, unless I am mistaken?
Here is my current Routing code:
render((
<BrowserRouter>
<Switch>
<Route exact path='/new-scenario' component={NewScenario}/>
<Route exact path='/about' component={About}/>
<Route exact path='/' component={Home}/>
</Switch>
</BrowserRouter>
), document.getElementById('root'));