2 ms·
useEffect should be used only when you want to bring something from outside the React tree which is not constant compared to the tree lifetime (anything that's
by skydhash 1y ago
useEffect should be used only when you want to bring something from outside the React tree which is not constant compared to the tree lifetime (anything that's not part of the UI module), hooking it to the tree lifecycle. useRef is for when you don't care the external thing's mutation. Any other hooks should be used when deriving from things that is already present in the React tree (props, local state, or other memoized variables)