Skip to content

schedule/cjs/schedule.<env>.js thinks it is in the browser when run on the server #13735

@RamIdeas

Description

@RamIdeas

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

Code meant to only run in the browser is running on the server. The error I'm seeing is:

UnhandledPromiseRejectionWarning: TypeError: window.addEventListener is not a function
      at ./node_modules/react-dom/node_modules/schedule/cjs/schedule.development.js:366:10
      at Object.<anonymous> (./node_modules/react-dom/node_modules/schedule/cjs/schedule.development.js:421:5)
      at Module._compile (module.js:653:30)
      at Object.Module._extensions..js (module.js:664:10)
      at Module.load (module.js:566:32)
      at tryModuleLoad (module.js:506:12)
      at Function.Module._load (module.js:498:3)
      at Module.require (module.js:597:17)
      at require (internal/module.js:11:18)
      at Object.<anonymous> (./node_modules/react-dom/node_modules/schedule/index.js:6:20)

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your JSFiddle (https://jsfiddle.net/Luktwrdm/) or CodeSandbox (https://codesandbox.io/s/new) example below:

We are using import { findDOMNode } from 'react-dom' in one of our components and the server render is broken due to this dependency/file being pulled in.

What is the expected behavior?

To not error, I guess. The root problem seems to be a faulty check of environment somewhere.

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?

This has been narrowed down to just 16.5.2 -- doing nothing but downgrading to 16.5.1 using npm install --save react@16.5.1 react-dom@16.5.1 fixes the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions