Loading...
(function(){<br />
let canvas = document.createElement('canvas'),<br />
ctx = canvas.getContext('2d'),<br />
w = canvas.width = innerWidth,<br />
h = canvas.height = innerHeight,<br />
particles = [],<br />
properties = {<br />
bgColor : 'rgba(17, 17, 19, 1)',<br />
particleColor : 'rgba(255, 40, 40, 1)',<br />
particleRadius : 3,<br />
particleCount : 60,<br />
particleMaxVelocity : 0.5,<br />
lineLength : 150,<br />
particleLife : 6,<br />
};<br />
<br />
document.querySelector('body').appendChild(canvas);<br />
<br />
window.onresize = function() {<br />
w = canvas.width = innerWidth;<br />
h = canvas.height = innerHeight;<br />
}<br />
<br />
class Particle {<br />
constructor() {<br />
this.x = Math.random()*w;<br />Loading...
You can use this when you need the initial page after authentication to have a URL different from /.
For this, use Navigate from react-router-dom.
Documentation:
https://reactrouter.com/en/main/components/navigate
1import { BrowserRouter as Router, Route, Routes, Navigate } from "react-router-dom";23// <...>4 <Routes>5 <Route6 exact7 path="/"8 element={9 <Navigate to="/home" />10 }11 >12 <Route13 exact14 path="home"15 element={16 <Home />17 }18 />19 </Routes>20// <...>21
For redirects inside a component, you can use useNavigate.
For example, if you need to redirect from an item page back to a list after deleting the item:
1import { useNavigate } from 'react-router-dom';23const SomeElement = () => {4 //<..>5 const navigate = useNavigate();67 const onDelete = () => {8 if(isDeleteSuccess){9 navigate(“/list”)10 }11 }1213 //<..>1415 return (16 //some JSX17 )18}1920export default SomeElement;