Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"react": "^0.13.0 || ^0.14.0 || ^15.0.0 || ^16.0.0"
},
"dependencies": {
"exenv": "^1.2.1",
"shallowequal": "^1.0.1"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const config = {
exclude: 'node_modules/**',
}),
],
external: ['shallowequal', 'react', 'exenv'],
external: ['shallowequal', 'react'],
}

if (BUILD_FORMAT === 'umd') {
Expand Down
9 changes: 7 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import React, { Component } from 'react';
import ExecutionEnvironment from 'exenv';
import shallowEqual from 'shallowequal';

const canUseDOM = !!(
typeof window !== 'undefined' &&
window.document &&
window.document.createElement
);

export default function withSideEffect(
reducePropsToState,
handleStateChangeOnClient,
Expand Down Expand Up @@ -46,7 +51,7 @@ export default function withSideEffect(
static displayName = `SideEffect(${getDisplayName(WrappedComponent)})`;

// Expose canUseDOM so tests can monkeypatch it
static canUseDOM = ExecutionEnvironment.canUseDOM;
static canUseDOM = canUseDOM;

static peek() {
return state;
Expand Down
3 changes: 1 addition & 2 deletions test/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const { expect } = require('chai');
const React = require('react');
const ExecutionEnvironment = require('exenv');
const jsdom = require('jsdom');
const { shallow, mount } = require('enzyme')
const { renderToStaticMarkup } = require('react-dom/server')
Expand Down Expand Up @@ -81,7 +80,7 @@ describe('react-side-effect', () => {
});

it('should expose the canUseDOM flag', () => {
expect(SideEffect).to.have.property('canUseDOM', ExecutionEnvironment.canUseDOM);
expect(SideEffect).to.have.property('canUseDOM');
});

describe('rewind', () => {
Expand Down
4 changes: 0 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1746,10 +1746,6 @@ esutils@^2.0.0, esutils@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b"

exenv@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/exenv/-/exenv-1.2.1.tgz#75de1c8dee02e952b102aa17f8875973e0df14f9"

expand-brackets@^0.1.4:
version "0.1.5"
resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-0.1.5.tgz#df07284e342a807cd733ac5af72411e581d1177b"
Expand Down