Side Effect ( after the initial render)
Act upon property updates
useEffect is similar to :
componentDidMount, componentDidUpdate, and componentWillUnmount
import { useEffect } from 'react';
function MyComponent(props) {
// ...
useEffect(() => {
const { subscribe } = props.store;
const unsubscribe = subscribe(...);
return unsubscribe
}, []);
return
}
Act up on a state change
useState
Used to store state for a functional component