Skip to content

Commit 3dad9ee

Browse files
authored
chore(README): Add FAQ and link to FB warning
Add links to FB's warning. Add FAQ about common issues
1 parent 6ef2da6 commit 3dad9ee

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

README.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Warning [![npm version](https://badge.fury.io/js/warning.svg)](https://badge.fury.io/js/warning)
2-
A mirror of Facebook's Warning
2+
A mirror of Facebook's [Warning](https://github.com/facebook/fbjs/blob/master/packages/fbjs/src/__forks__/warning.js)
33

44

55
## Usage
@@ -20,11 +20,30 @@ warning(
2020
// 'This thing should be true but you set to false. No soup for you!'
2121
```
2222

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.
2424
This can be used to log issues in development environments in critical
2525
paths. Removing the logging code for production environments will keep the
2626
same logic and follow the same code paths.
2727

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+
2847
## Browserify
2948

3049
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

Comments
 (0)