JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2428751
  • Score
    100M100P100Q191362F
  • License BSD

React's ExecutionEnvironment module extracted for use in other packages & components

Package Exports

  • exenv

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (exenv) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

exenv

React's ExecutionEnvironment module extracted for use in other packages & components.

Why?

Because a lot of packages and components use React's private ExecutionEnvironment lib to detect the environment, e.g

canUseDOM = require('react/lib/ExecutionEnvironment').canUseDOM;

It is bad practice to use React internals and this is likely to be broken / disabled in the future. Use this package instead.

Usage

npm install exenv --save
var ExecutionEnvironment = require('exenv');

// You now have...
ExecutionEnvironment.canUseDOM             // is the DOM available? i.e window document etc. 
ExecutionEnvironment.canUseWorkers         // are Web Workers available?
ExecutionEnvironment.canUseEventListeners  // are Events available? i.e addEventListener etc.
ExecutionEnvironment.canUseViewport        // is there a viewport? i.e window.screen