@@ -32,15 +32,15 @@ type ConstateTuple<Props, Value, Selectors extends Selector<Value>[]> = [
3232 ...Hooks < Value , Selectors >
3333] ;
3434
35- const isDev = process . env . NODE_ENV !== "production" ;
36-
3735const NO_PROVIDER = { } ;
3836
3937function createUseContext ( context : React . Context < any > ) : any {
4038 return ( ) => {
4139 const value = React . useContext ( context ) ;
42- if ( isDev && value === NO_PROVIDER ) {
43- console . warn ( "Component must be wrapped with Provider." ) ;
40+ if ( process . env . NODE_ENV !== "production" ) {
41+ if ( value === NO_PROVIDER ) {
42+ console . warn ( "Component must be wrapped with Provider." ) ;
43+ }
4444 }
4545 return value ;
4646 } ;
@@ -55,8 +55,10 @@ export function constate<Props, Value, Selectors extends Selector<Value>[]>(
5555
5656 const createContext = ( displayName : string ) => {
5757 const context = React . createContext ( NO_PROVIDER ) ;
58- if ( isDev && displayName ) {
59- context . displayName = displayName ;
58+ if ( process . env . NODE_ENV !== "production" ) {
59+ if ( displayName ) {
60+ context . displayName = displayName ;
61+ }
6062 }
6163 contexts . push ( context ) ;
6264 hooks . push ( createUseContext ( context ) ) ;
@@ -103,8 +105,10 @@ export function constate<Props, Value, Selectors extends Selector<Value>[]>(
103105 return [ inject , value ] ;
104106 } ;
105107
106- if ( isDev && useValue . name ) {
107- ConstateProvider . displayName = "Constate" ;
108+ if ( process . env . NODE_ENV !== "production" ) {
109+ if ( useValue . name ) {
110+ ConstateProvider . displayName = "Constate" ;
111+ }
108112 }
109113
110114 return [ ConstateProvider , ...hooks ] ;
0 commit comments