Skip to content

Commit

Permalink
Avoid setImmediate()
Browse files Browse the repository at this point in the history
Summary: `setImmediate()` is not well supported (https://caniuse.com/?search=setImmediate) switch to `window.setTimeout()` instead.

Differential Revision: D35338923

fbshipit-source-id: 38cb926c5307eee39dbdeedefac729e86abf39ac
  • Loading branch information
drarmstr authored and facebook-github-bot committed Apr 3, 2022
1 parent d922baa commit a8f2403
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/recoil-sync/RecoilSync.js
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ function syncEffect<T>(opt: SyncEffectOptions<T>): AtomEffect<T> {
// Persist on Initial Read
const writeToStorage = storage?.write;
if (options.syncDefault === true && writeToStorage != null) {
setImmediate(() => {
window.setTimeout(() => {
const loadable = getLoadable(node);
if (loadable.state === 'hasValue') {
const diff = writeAtomItemsToDiff(
Expand All @@ -585,7 +585,7 @@ function syncEffect<T>(opt: SyncEffectOptions<T>): AtomEffect<T> {
getWriteInterface(storeID, storeKey, diff, getInfo_UNSTABLE),
);
}
});
}, 0);
}
}

Expand Down

0 comments on commit a8f2403

Please sign in to comment.