notes on react framework
Why do we use states? States are used to store encapsulated data.
- It's one of the lifecycle method on JavaScript.
- We use it to fetch data, store something as array etc.
- For making any request useEffect is being used and after making request we can store something as array.
useEffect(() => {
// effect geoes here or request code.
}, [array]); // here inside [] we store our things.
// So whenever we make a request we need to make sure the request goes once.
// on the 2nd aurgument the [] creates epmty set of arrays to store something.
// the 2nd aurgument ensures that the useEffect should run once.