mirror of
https://github.com/m-lamonaca/dev-notes.git
synced 2025-04-08 11:56:41 +00:00
Typo fixes
This commit is contained in:
parent
990709787c
commit
a97fd80966
1 changed files with 17 additions and 17 deletions
|
@ -46,24 +46,10 @@ import { Route, Switch } from "react-router-dom";
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route path="/" exact component={Component} />
|
<Route path="/" exact component={Component} />
|
||||||
<Route path="/route" component={Component} />
|
<Route path="/route" component={Component} />
|
||||||
<Route component={PageNotFound} /> {/* mathes all non-existent URLs */}
|
<Route component={PageNotFound} /> {/* matches all non-existent URLs */}
|
||||||
</Switch>
|
</Switch>
|
||||||
```
|
```
|
||||||
|
|
||||||
### Redirectin
|
|
||||||
|
|
||||||
```js
|
|
||||||
import { Redirect } from "react-router-dom";
|
|
||||||
|
|
||||||
// redirects to another URL, should'nt be rendered on component mount but after an action
|
|
||||||
<Redirect to="/route" />
|
|
||||||
<Redirect from="/old-route" to="/new-route" />
|
|
||||||
{ condition && <Redirect to="/route" /> } // redirect if condition is true
|
|
||||||
|
|
||||||
// or redirect manipolating the history (alwais in props)
|
|
||||||
props.history.push("/new-route");
|
|
||||||
```
|
|
||||||
|
|
||||||
### URL Parameters & Query String
|
### URL Parameters & Query String
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
@ -78,12 +64,26 @@ function Component(props) {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Propts
|
### Redirecting
|
||||||
|
|
||||||
|
```js
|
||||||
|
import { Redirect } from "react-router-dom";
|
||||||
|
|
||||||
|
// redirects to another URL, should'nt be rendered on component mount but after an action
|
||||||
|
<Redirect to="/route" />
|
||||||
|
<Redirect from="/old-route" to="/new-route" />
|
||||||
|
{ condition && <Redirect to="/route" /> } // redirect if condition is true
|
||||||
|
|
||||||
|
// or redirect manipolating the history (always in props)
|
||||||
|
props.history.push("/new-route");
|
||||||
|
```
|
||||||
|
|
||||||
|
### Prompts
|
||||||
|
|
||||||
```js
|
```js
|
||||||
import { Prompt } from "react-router-dom";
|
import { Prompt } from "react-router-dom";
|
||||||
|
|
||||||
// displayes a prompt when the conditioni true
|
// displayes a prompt when the condition is true
|
||||||
<Prompt when={condition} message="prompt message" />
|
<Prompt when={condition} message="prompt message" />
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue