You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A mirror of Facebook's [Warning](https://github.com/facebook/fbjs/blob/master/packages/fbjs/src/__forks__/warning.js)
3
3
4
4
5
5
## Usage
@@ -20,11 +20,30 @@ warning(
20
20
// 'This thing should be true but you set to false. No soup for you!'
21
21
```
22
22
23
-
Similar to Facebook's invariant but only logs a warning if the condition is not met.
23
+
Similar to Facebook's (FB) invariant but only logs a warning if the condition is not met.
24
24
This can be used to log issues in development environments in critical
25
25
paths. Removing the logging code for production environments will keep the
26
26
same logic and follow the same code paths.
27
27
28
+
## FAQ (READ before opening an issue)
29
+
30
+
> Why do you use `console.error` instead of `console.warn` ?
31
+
32
+
This is a mirror of Facebook's (FB) [warning](https://github.com/facebook/fbjs/blob/master/packages/fbjs/src/__forks__/warning.js) module used within React's source code (and other FB software).
33
+
As such this module will mirror their code as much as possible.
34
+
35
+
The descision to use `error` over `warn` was made a long time ago by the FB team and isn't going to change anytime soon.
36
+
37
+
The source can be found here: https://github.com/facebook/fbjs/blob/master/packages/fbjs/src/__forks__/warning.js
38
+
The reasoning can be found here and elsewhere: https://github.com/facebook/fbjs/pull/94#issuecomment-168332326
39
+
40
+
> Can I add X feature?
41
+
42
+
This is a mirror of Facebook's (FB) [warning](https://github.com/facebook/fbjs/blob/master/packages/fbjs/src/__forks__/warning.js) and as such the source and signature will mirror that module.
43
+
44
+
If you believe a feature is missing than please open a feature request [there](https://github.com/facebook/fbjs).
45
+
If it is approved and merged in that this module will be updated to reflect that change, otherwise this module will not change.
46
+
28
47
## Browserify
29
48
30
49
When using [browserify](http://browserify.org/), the `browser.js` file will be imported instead of `invariant.js` and browserify will be told to transform the file with [envify](https://github.com/hughsk/envify). The only difference between `browser.js` and `invariant.js` is the `process.env.NODE_ENV` variable isn't cached. This, in combination with envify and (optionally) [uglifyjs](https://github.com/mishoo/UglifyJS), will result in a noop in production environments. Otherwise behavior is as expected.
0 commit comments