I have been studying about the useEffect hook in reactjs. and i studied the we can not pass parameters to useEffect function, this is understandable. but tried to search for the reason the why is it not allowed to pass parameters in useEffect function.
useEffect((parameter)=> {
console.log(parameter)
})
does anyone know?
I searched alot for it, but i could not find any reasonable answer for it.
The function passed to
useEffectin React is not designed to receive parameters directly because it is called by React and not by your code directly. To use parameters inside the effect function, you can use variables from the scope of the component or define the effect function inside the component where it can access the component's state and props.