You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
}).toThrow("Cannot read property 'useState' of null");
283
+
}).toErrorDev(
282
284
'Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for'+
283
285
' one of the following reasons:\n'+
284
286
'1. You might have mismatching versions of React and the renderer (such as React DOM)\n'+
285
287
'2. You might be breaking the Rules of Hooks\n'+
286
288
'3. You might have more than one copy of React in the same app\n'+
287
289
'See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.',
it('throws when called outside the render phase',()=>{
252
-
expect(()=>useState(0)).toThrow(
252
+
expect(()=>{
253
+
expect(()=>useState(0)).toThrow(
254
+
"Cannot read property 'useState' of null",
255
+
);
256
+
}).toErrorDev(
253
257
'Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for'+
254
258
' one of the following reasons:\n'+
255
259
'1. You might have mismatching versions of React and the renderer (such as React DOM)\n'+
256
260
'2. You might be breaking the Rules of Hooks\n'+
257
261
'3. You might have more than one copy of React in the same app\n'+
258
262
'See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.',
'Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for'+
30
-
' one of the following reasons:\n'+
31
-
'1. You might have mismatching versions of React and the renderer (such as React DOM)\n'+
32
-
'2. You might be breaking the Rules of Hooks\n'+
33
-
'3. You might have more than one copy of React in the same app\n'+
34
-
'See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.',
35
-
);
36
-
returndispatcher;
26
+
if(__DEV__){
27
+
if(dispatcher===null){
28
+
console.error(
29
+
'Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for'+
30
+
' one of the following reasons:\n'+
31
+
'1. You might have mismatching versions of React and the renderer (such as React DOM)\n'+
32
+
'2. You might be breaking the Rules of Hooks\n'+
33
+
'3. You might have more than one copy of React in the same app\n'+
34
+
'See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.',
35
+
);
36
+
}
37
+
}
38
+
// Will result in a null access error if accessed outside render phase. We
39
+
// intentionally don't throw our own error because this is in a hot path.
0 commit comments