In class Components, we use componentDidMount, componentDidUpdate lifecycle method to update the state. ex)
componentDidMount() {
document.title = `You clicked ${this.state.count} times`;
}
componentDidUpdate() {
document.title = `You clicked ${this.state.count} times`;
}
It runs after every render(componentDidUpdate) including first render(componentDidMount). In useEffect hook, we can implment this functionality like this
useEffect(() => {
document.title = `You clicked ${count} times`;
});
Do these 2 methods have the same effect?
I read this section Reactjs.org and I've tried it on React.js vs 16. I think these 2 methods have the same effects.
useEffect(() => {
document.title = `You clicked ${count} times`;
});