I have a simple useEffect function setup with the brackets like so:
useEffect(() => {
console.log('hello')
getTransactions()
}, [])
However when I run my app, it prints two hellos in the console. Any idea why?
Even if I add something like this, two hellos print still.
const [useEffectCalled, setUseEffectCalled] = useState<Boolean>(false)
useEffect(() => {
console.log('hello')
if (!useEffectCalled) {
getTransactions()
}
setUseEffectCalled(true)
}, [])
getTransactionsis causing a complete re-loading (or remounting) of the component, triggering it once again? Comment it out and see if it still triggers twice, try to locate where the problem is exactly.getTransactionsjust including theconsole.login useEffect and same thing, logged two hellos...strangest thing