1.2.2 • Published 7 years ago

exenv v1.2.2

Weekly downloads
1,774,442
License
BSD-3-Clause
Repository
github
Last release
7 years ago

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!

react-modal@sprucelabs/react-heartwood-components@dterekhova/componentsdivanru-ui@instamotor-labs/nuka-carouselsacho-reactreact-recommender@everything-registry/sub-chunk-1627react-hattreact-key-eventsreact-key-handlerreact-keystackseneca-componentsdulcet-side-effectsnabbdom-materialerasme-kepler.gleryk-sandecki-test-test-3react-observable-subscribereact-modal2react-modalsreact-modal-onedesertreact-modal-onfidoreact-modal-copyreact-redux-provide-historyreact-redux-provide-pagereact-redux-provide-themereact-relative-portalreact-router-oldreact-reffectreact-orphanage@dgknca/react-stack-grid@dailybeast/react-media-query@cruisecritic/react-gpt@delewis13/react-joyridereact-without-hydrationreact-tooltipsreact-wildcat-hot-reloaderreact-wildcat-prefetchruler-componentsanjeev-react-joyridereact-single-sourcingreactackle-autopositionreact-sodreact-twitter-timeline-widgetsreact-stack-gridreact-stack-grid-compatreact-stack-grid-jaivanareact-stack-grid-xaviergonz-fixreact-sprucebotreact-vision-domretail-uiretail-ui-auto-build-demorheo-react-joyriderheo-test-react-joyridereact-safety-helmetreact-scrolllockreact-scrolllock-configurablereact-scrolllock-reactrefreact-scrolllock-with-horizontal-scrollrmc-nuka-carouselcss-keyframerreact-grid-imagedk-react-modalsitepack-react@baum/nuka-carousel@barbershopio/react-sprucebot@banzai-inc/react-key-handleroxygen-rteoxygen-uicf-component-dropdown@blablacar/ui-libraryparabaik-uiparamount-ui@catapult-tech/cp-design-system-actionmenu@catapult-tech/cp-design-system-dropdown@catapult-tech/cp-design-system-position@catapult-tech/cp-design-system-util@carto/kepler.gl@carlos.algms/react-gpt@chrisuh10/react-spotify-web-playback@cgomes/react-gpt@cloudflare/component-dropdown@cloudflare/component-modal@clinia/react-vizion-domwords-app-components@slate-editor/alignment-plugin@slate-editor/color-plugin@slate-editor/components@slate-editor/embed-plugin@slate-editor/font-size-plugin@slate-editor/grid-plugin@slate-editor/image-plugin@slate-editor/link-plugin@slate-editor/list-pluginxavient-relative-portalproofpoint-radium@codingcatdev/react-gptprovide-themeprovide-page@cross2d/nuka-carousel
1.2.2

7 years ago

1.2.1

8 years ago

1.2.0

9 years ago

1.1.0

9 years ago

1.0.0

9 years ago