Comparing version 1.0.0 to 1.1.0
11
index.js
/** | ||
* Copyright 2013-2015, Facebook, Inc. | ||
* Based on code that is Copyright 2013-2015, Facebook, Inc. | ||
* All rights reserved. | ||
@@ -14,7 +14,2 @@ */ | ||
/** | ||
* Simple, lightweight module assisting with the detection and context of | ||
* Worker. Helps avoid circular dependencies and allows code to reason about | ||
* whether or not they are in a Worker. | ||
*/ | ||
var ExecutionEnvironment = { | ||
@@ -29,8 +24,6 @@ | ||
canUseViewport: canUseDOM && !!window.screen, | ||
canUseViewport: canUseDOM && !!window.screen | ||
isInWorker: !canUseDOM // For now, this is true - might change in the future. | ||
}; | ||
module.exports = ExecutionEnvironment; |
{ | ||
"name": "exenv", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "React's ExecutionEnvironment module extracted for use in other packages & components", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -5,12 +5,2 @@ # exenv | ||
## 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 | ||
@@ -30,2 +20,18 @@ | ||
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! |
3985
36
18