V
V
Vann Damm2020-05-25 21:20:14
JavaScript
Vann Damm, 2020-05-25 21:20:14

How to create a Route with a path depending on the requests passed to the route component?

Code not working:

<Route path={"/:form?"} component={()=><LoginFormer form={form? "reregistration" : "login"} changeFormReg={changeFormForRegistation} changeFormLogin={changeFormForLogin} />} />


I need that, depending on the form prop, a url is formed for the LoginFormer component. I don't understand how to achieve this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2020-05-25
@effect_tw

Inside the component, you read the props and make a redirect, for example, through window. location

V
Vladimir, 2020-05-25
@Casufi

Once again, do you want to show different components in one route depending on the prop?
https://reacttraining.com/react-router/core/api/Ro...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question