Using react hooks inside any function of condition is invalid. Neither can I do conditional rendering for a hook. Is there any way to use a hook with emplement condition? Please share code
CodePudding user response:
The only way
useEffect(() => {
if (!!myparam) {
console.log("myparam", myparam)
}
}, [myparam])
CodePudding user response:
Can you please provide us any code snippet which your are trying to do?
If you are using useEffect hook then for conditional rendering you can do following code.
UseEffect(()=> { if(true) { Do some logic.}}, []);
UseEffect(()=> { Do some logic. }, [Add your state here])