You Might Not Need an Effect
has been live for, at the very least, a couple of years now. It has really helped! However, I keep seeing at least one incorrect and widely-spread usage of useEffect
s: server/local state synchronization.
const Edit = ({ data, onSave }) => {
const [dynamicData, setDynamicData] = useState(data)
useEffect(() => {
setDynamicData(data) // Don't do this!