• Stars
    star
    225
  • Rank 177,187 (Top 4 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 9 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A mirror of Facebook's Warning

Warning npm version

Greenkeeper badge A mirror of Facebook's Warning

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 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: facebook/fbjs#94 (comment)

Can I add X feature?

This is a mirror of Facebook's (FB) warning 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. 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 with this module to remove warning messages in production.
















Don't Forget To Be Awesome

More Repositories

1

react-material

Material design components written with React.js and React Style
HTML
404
star
2

react-vimeo

React component to load video from Vimeo
JavaScript
77
star
3

redux-epic

Better async and server side rendering in React with Observables
JavaScript
47
star
4

react-redux-epic

JavaScript
37
star
5

dotfiles

My workstation dotfiles
Clojure
21
star
6

redux-create-types

A better way to create types!
JavaScript
14
star
7

conduit-go-htmx

A real world example app using Go, Templ, Sqlc, and HTMX
Go
10
star
8

zmk-keyboards

My zmk config for a 5 column wireless Corne
C++
7
star
9

tnskyfmt-fnl

Fennel formatter following [Tonsky's style](https://tonsky.me/blog/clojurefmt/) indenting
Lua
7
star
10

react-redux-subdivide

JavaScript
6
star
11

r3dm.com

Totally awesome fun time reactjs FRP flux isomorph-tastic site
HTML
5
star
12

rxjs-redux-and-wizardry

RxJS: Redux and Wizardry
JavaScript
3
star
13

ethernaut-cljs

Clojure
2
star
14

react-rxjs-and-you

Async and You
JavaScript
2
star
15

berkeleys-snippet-emporium

vim snippets for react.
Vim Snippet
2
star
16

crypto-egg

CLI/Service to query current crypto prices using on chain data
Clojure
2
star
17

redux-vertical

Do Redux Vertically
TypeScript
2
star
18

intro-to-redux

JavaScript
2
star
19

conduit-clj-htmx

A RealWorld example app built with Clojure, HTMX, and XTDB
Clojure
2
star
20

berkeleys-redux-utils

JavaScript
1
star
21

dotcom

Logic becomes you.
HTML
1
star
22

lumo-todo

Clojure
1
star
23

berkeleytrue

1
star
24

crypto-egg-go

A CLI/server crypto price aggregator written in Go
Go
1
star
25

storeleft

An offline-first personal inventory management system built in Nextjs with Pouchdb
TypeScript
1
star
26

wndlr

JavaScript
1
star
27

homelab

Nix
1
star
28

redux-verticals-talk

JavaScript
1
star
29

conduit-purescript

A conduit example in purescript
PureScript
1
star
30

home-manager-parts

A `flake-parts` home-manager integration
Nix
1
star
31

berkeleys-spectacle-boilerplate

JavaScript
1
star
32

nix-boulder-banner

A `flake-parts` module that adds banners to your nix dev shells
Nix
1
star
33

eslint-plugin-arrow-body-parens

JavaScript
1
star