Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit be1f921

Browse files
committed
Check the presence of process.env
1 parent d42843e commit be1f921

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

packages/warning/src/index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
function isDev() {
2+
return (
3+
typeof process !== 'undefined' &&
4+
process.env &&
5+
process.env.NODE_ENV !== 'production'
6+
);
7+
}
8+
19
/**
210
* Shows a warning with `messages` if `condition` passes and environment is not `production`.
311
*
@@ -15,7 +23,7 @@
1523
* ```
1624
*/
1725
export default function warning( condition, ...messages ) {
18-
if ( process.env.NODE_ENV !== 'production' ) {
26+
if ( isDev() ) {
1927
if ( ! condition ) {
2028
return;
2129
}

0 commit comments

Comments
 (0)