Undo Prettier auto-formatting
This commit is contained in:
10
snippets/redirect-to-URL.md
Normal file
10
snippets/redirect-to-URL.md
Normal file
@ -0,0 +1,10 @@
|
||||
### Redirect to URL
|
||||
|
||||
Use `window.location.href` or `window.location.replace()` to redirect to `url`.
|
||||
Pass a second argument to simulate a link click (`true` - default) or an HTTP redirect (`false`).
|
||||
|
||||
```js
|
||||
const redirect = (url, asLink = true) =>
|
||||
asLink ? window.location.href = url : window.location.replace(url);
|
||||
// redirect('https://google.com')
|
||||
```
|
||||
Reference in New Issue
Block a user