Skip to content

Commit

Permalink
Data: Registry - check for window (#9261)
Browse files Browse the repository at this point in the history
* Data: Registry - check for window

The registry code is blindly deferencing window, which will fail if ever
run in node for test or server-side rendering. This adds a simple check
to ensure window exists before dereferencing.

* Data: Check window type before using
  • Loading branch information
coderkevin authored and gziolo committed Aug 25, 2018
1 parent a6ac21d commit 7db0880
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/data/src/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export function createRegistry( storeConfigs = {} ) {
*/
function registerReducer( reducerKey, reducer ) {
const enhancers = [];
if ( window.__REDUX_DEVTOOLS_EXTENSION__ ) {
if ( typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION__ ) {
enhancers.push( window.__REDUX_DEVTOOLS_EXTENSION__( { name: reducerKey, instanceId: reducerKey } ) );
}
const store = createStore( reducer, flowRight( enhancers ) );
Expand Down

0 comments on commit 7db0880

Please sign in to comment.