tannerlinsley / use-react-hooks

Use hooks in classes in React 16.5+
https://codesandbox.io/s/wor3rxopv8
81 stars 4 forks source link

useEffect should run asynchronously #1

Open RoystonS opened 6 years ago

RoystonS commented 6 years ago

Hi there - nice-looking work so far! One little thing I noticed: I think useEffect is meant to schedule the effect to run asynchronously, after rendering has completed (e.g. via requestAnimationFrame). useLayoutEffect and useMutationEffect run closer to the original render() function timing, but useEffect runs later.

(A quick trial with real React 16.7 alpha shows that work scheduled with useEffect runs after work scheduled with requestAnimationFrame, and definitely way after rendering.)

tannerlinsley commented 6 years ago

Would love to see a PR to fix this then :)