Socket
Socket
Sign inDemoInstall

exenv

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

exenv

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


Version published
Maintainers
1
Weekly downloads
1,706,764
decreased by-18.93%
Install size
4.92 kB

Weekly downloads

Readme

Source

exenv

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

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

Differences from React's ExecutionEnvironment

The ExecutionEnvironment lib in React 0.13 includes an isInWorker property, which is !canUseDOM. This is highly specific to React internals and probably (a) hacky and (b) not useful to other packages, so it has been left out. Please open an issue with your thoughts if you disagree or have a better idea.

Why?

A number of packages and components use React's private ExecutionEnvironment lib to detect available features, particularly to detect server-side rendering, e.g

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

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

Use this package instead!

Keywords

FAQs

Last updated on 23 Apr 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc