Configure useEffect

PHOTO EMBED

Sat Jan 08 2022 14:35:34 GMT+0000 (UTC)

Saved by @bapateprachee #react.js

1) using [],  Only once when component is intially rendered
useEffect(() => {
  console.log('inside use effect')
}, [])

2) nothing, run at initial render and at every single re-render
useEffect(() => {
  console.log('inside use effect')
})

2)[selectedItem], everytime whenever the state of selectedItem changes
useEffect(() => {
  console.log('inside use effect')
}, [selectedItem])

3) [selectedItem > 2], everytime the condition matches
useEffect(() => {
  console.log('inside use effect')
}, [selectedItem > 2])
content_copyCOPY