E7 - Finding the Path
Routing can be mysterious, but we'll unravel the secrets in this episode. You'll gain a deep understanding of routes, paths, and how to navigate to different sections of your app with precision.
Reference links from pdf notes & assignments
- test
- test
key points
-
useEffect life cycle with dependency array
- If No dependency array [] is passed, it will run on every render of the component:
useEffect(() => {
console.log("it will run on every render of the component");
}); - if empty dependency array is passed as dependency array, it will run only once when the component mounts initially
useEffect(() => {
console.log("it will run only once when the component mounts initially");
}, []); - if array with dependencies is passed, it will run when the component mounts and when the dependencies change/updated
useEffect(() => {
console.log("will run when dependencies array change/updated");
}, [dataList]);
- If No dependency array [] is passed, it will run on every render of the component:
-
useState
- Never use useState outside of your components, will get error
- Almost keep useState at begin / top of components
- Never create useState react variables inside any conditional statements like if else, for loops, inside functions
if(){
const [searchValue, setSearchValue] = useState("");
}
-
How to use router / navigation to other pages in react apps ?
- use react-router-dom lib, https://reactrouter.com/home
-
Never use anchor tag inside react apps
-
Routing in web apps - 2 types
- client side routing
- server side routing
-
Dynamic routing
Assignments - Q & A
1.sada
2.asda