From bdfc4fdb31860629176a4cdc8b48d5e1953bd5a6 Mon Sep 17 00:00:00 2001 From: midzer Date: Tue, 21 Dec 2021 02:39:16 +0100 Subject: [PATCH] replace setTimeout --- withSubscribe.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/withSubscribe.js b/withSubscribe.js index 47b0d3d..a45aa0a 100644 --- a/withSubscribe.js +++ b/withSubscribe.js @@ -1,7 +1,7 @@ module.exports = createStore => (reducer,...args) => { const listeners = [] const wrapped = (state, action) => ( - action && action.type != '@@init' && setTimeout(() => listeners.forEach(listener => listener()), 0), + action && action.type != '@@init' && window.requestAnimationFrame(() => listeners.forEach(listener => listener())), reducer(state, action) ) const store = createStore(wrapped, ...args)