I'm using a React Native functional component as follows:
export const Component1 = () => {
const [var1, setVar1] = useState(false);
setVar1(false);
return (
<View...>
)
}
This goes into an infinite loop, but when I remove the setVar1(false)
, it doesn't. I assumed the component wouldn't re-render if I kept re-setting var1
to the same false
value. How do I prevent this re-render?