()
| 22 | type Dispatch<A> = A => void; |
| 23 | |
| 24 | function resolveDispatcher() { |
| 25 | const dispatcher = ReactSharedInternals.H; |
| 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://react.dev/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. |
| 40 | // Also helps ensure this is inlined. |
| 41 | return ((dispatcher: any): Dispatcher); |
| 42 | } |
| 43 | |
| 44 | export function getCacheForType<T>(resourceType: () => T): T { |
| 45 | const dispatcher = ReactSharedInternals.A; |
no test coverage detected