reakit-warning
v0.6.2
Published
Reakit warning
Downloads
548,710
Readme
reakit-warning
This is experimental and may have breaking changes in minor versions.
Installation
npm:
npm i reakit-warning
Yarn:
yarn add reakit-warning
Reducing bundle size
Literal strings aren't minified. Keeping them in your production bundle may increase the bundle size significantly.
To prevent that, you should:
Put
reakit-warning/babel-plugin
into your babel config.This will make sure your
warning
anduseWarning
calls are wrapped within a condition that checks ifprocess.env.NODE_ENV !== 'production'
.Use UglifyJS, Terser or any other JavaScript parser that performs dead code elimination. This is usually used in conjunction with JavaScript bundlers, such as webpack.
When parsing the code in
production
mode, thewarning
call will be removed altogether.
API
Table of Contents
useWarning
Logs messages
to the console using console.warn
based on a condition
.
This should be used inside components.
Parameters
warning
Logs messages
to the console using console.warn
based on a condition
.
Parameters
Examples
import { warning } from "reakit-warning";
warning(true, "a", "b"); // console.warn("a", "\n", "b")
warning(false, "a", "b"); // does nothing
License
MIT © Diego Haz