Created
July 25, 2020 17:45
-
-
Save berkelmas/3fe907c685be8c495c83b25e8439df5e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, {useEffect, useState} from "react"; | |
const ExampleUseEffect = props => { | |
const [exampleState, setExampleState] = useState({name: "Berk"}) | |
useEffect(() => { | |
console.log("I execute in component's first render.") | |
}, []); | |
useEffect(() => { | |
console.log("I execute when exampleState state changes."); | |
}, [exampleState]) | |
useEffect(() => { | |
console.log("I execute when props changes.") | |
}, [props]) | |
useEffect(() => { | |
console.log("I execute every single render of my component.") | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment