Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve promise on server side rendering as endBatch is only called o…
…n useEffect (facebookexperimental#2073) Summary: Reference Issue: [https://github.com/facebookexperimental/Recoil/issues/1960](https://github.com/facebookexperimental/Recoil/issues/1960) The function sendEndOfBatchNotifications is only executed on useEffect as below: ``` useEffect(() => { // enqueueExecution runs this function immediately; it is only used to // manipulate the order of useEffects during tests, since React seems to // call useEffect in an unpredictable order sometimes. Queue.enqueueExecution('Batcher', () => { endBatch(storeRef.current); }); }); ``` This caused the SSR usage of async selector to get stuck in infinite loading. With this PR, we make sure that when the original promise is resolved, we resolve the `handleLoadable` promise as well. Thus making it compatible with SSR rendering Pull Request resolved: facebookexperimental#2073 Differential Revision: https://www.internalfb.com/diff/D40948099?entry_point=27 Pulled By: drarmstr fbshipit-source-id: 9ac77a898ecd118005d87ddf0a461478cf498488
- Loading branch information