# warning

> A mirror of Facebook's Warning

Latest version **4.0.3** (published 2019-02-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install warning
pnpm add warning
yarn add warning
bun add warning
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.3 |
| Published | 2019-02-09 |
| First published | 2015-04-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/warning) |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 9.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 220 |
| Author | Berkeley Martinez |
| Maintainers | berkeleytrue |
| Keywords | warning, facebook, react, invariant |

## Links

- npm: https://www.npmjs.com/package/warning
- Repository: https://github.com/BerkeleyTrue/warning
- Issues: https://github.com/BerkeleyTrue/warning/issues
- npm.io page: https://npm.io/package/warning

## Dependencies (1)

- [loose-envify](https://npm.io/package/loose-envify.md) ^1.0.0

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 4.0.3 (latest) — 2019-02-09
- 4.0.2 — 2018-08-17
- 4.0.1 — 2018-05-30
- 4.0.0 — 2018-05-22
- 3.0.0 — 2016-06-03
- 2.1.0 — 2015-10-04
- 2.0.0 — 2015-07-12
- 1.0.2 — 2015-05-30
- 1.0.1 — 2015-04-09
- 1.0.0 — 2015-04-01

## README

# Warning [![npm version](https://badge.fury.io/js/warning.svg)](https://badge.fury.io/js/warning)

[![Greenkeeper badge](https://badges.greenkeeper.io/BerkeleyTrue/warning.svg)](https://greenkeeper.io/)
A mirror of Facebook's [Warning](https://github.com/facebook/fbjs/blob/master/packages/fbjs/src/__forks__/warning.js)


## Usage
```
npm install warning
```

```
// some script
var warning = require('warning');

var ShouldBeTrue = false;

warning(
  ShouldBeTrue,
  'This thing should be true but you set to false. No soup for you!'
);
//  'This thing should be true but you set to false. No soup for you!'
```

Similar to Facebook's (FB) invariant but only logs a warning if the condition is not met.
This can be used to log issues in development environments in critical
paths. Removing the logging code for production environments will keep the
same logic and follow the same code paths.

## FAQ (READ before opening an issue)

> Why do you use `console.error` instead of `console.warn` ?

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).
As such this module will mirror their code as much as possible. 

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.

The source can be found here: https://github.com/facebook/fbjs/blob/master/packages/fbjs/src/__forks__/warning.js
The reasoning can be found here and elsewhere: https://github.com/facebook/fbjs/pull/94#issuecomment-168332326

> Can I add X feature?

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.

If you believe a feature is missing than please open a feature request [there](https://github.com/facebook/fbjs).
If it is approved and merged in that this module will be updated to reflect that change, otherwise this module will not change.

## Use in Production

It is recommended to add [babel-plugin-dev-expression](https://github.com/4Catalyzer/babel-plugin-dev-expression) with this module to remove warning messages in production.
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<small>Don't Forget To Be Awesome</small>

---
_Source: https://npm.io/package/warning · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
