From ee717af0889312cc6cc6337da0d405356a5a2a58 Mon Sep 17 00:00:00 2001 From: Stephen Mathieson Date: Fri, 27 Jan 2017 18:33:42 -0800 Subject: [PATCH] examples/with-redux: remove global store (#908) This patch removes the global `store` on the client. IMO this example should avoid polluting the global namespace with simple scoping tricks can solve the problem equally as well. --- examples/with-redux/store.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/with-redux/store.js b/examples/with-redux/store.js index 250e47f2..be0fc159 100644 --- a/examples/with-redux/store.js +++ b/examples/with-redux/store.js @@ -12,13 +12,15 @@ export const startClock = () => dispatch => { return setInterval(() => dispatch({ type: 'TICK', light: true, ts: Date.now() }), 800) } +let store = null + export const initStore = (reducer, initialState, isServer) => { if (isServer && typeof window === 'undefined') { return createStore(reducer, initialState, applyMiddleware(thunkMiddleware)) } else { - if (!window.store) { - window.store = createStore(reducer, initialState, applyMiddleware(thunkMiddleware)) + if (!store) { + store = createStore(reducer, initialState, applyMiddleware(thunkMiddleware)) } - return window.store + return store } }