useState
is similiar to an object / variable, allowing us to create dinamic components:
[ VAR, SETTER]
// state variable
const [tasks, setTasks] = useState([]);
useEffect
is a side effect function ( that's going to be activated after something like the page renderization ):
// This is a side effect (runs after the render)
useEffect(() => {
async function loadTasks() {
const res = await getAllTasks();
console.log(res);
setTasks(res.data);
}
loadTasks();
}, []);
useNavigate
is the hook that allow navigation / redirect without page refresh:
// Navigator to redirect to the App.js specified route path
const navigate = useNavigate();
const handleClick = () => {
navigate("/tasks/" + task.title);
};