File tree Expand file tree Collapse file tree 1 file changed +18
-15
lines changed
packages/node_modules/overmind-react/src Expand file tree Collapse file tree 1 file changed +18
-15
lines changed Original file line number Diff line number Diff line change 11import { BaseApp , EventType , Overmind , Configuration } from 'overmind'
22import * as React from 'react'
3- // @ts -ignore
4- import { useEffect , useState } from 'react'
3+ import {
4+ // @ts -ignore
5+ useEffect ,
6+ // @ts -ignore
7+ useState ,
8+ // @ts -ignore
9+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED ,
10+ } from 'react'
511
612export type IReactComponent < P = any > =
713 | React . StatelessComponent < P >
@@ -29,21 +35,18 @@ export type TConnect<App extends BaseApp> = {
2935
3036let nextComponentId = 0
3137
32- type FunctionComponent = {
33- ( ...args : any [ ] ) : React . ReactChildren
34- __componentId : number
35- displayName : string
36- }
37-
3838export const createHook = < App extends Overmind < Configuration > > ( app : App ) => {
3939 let componentInstanceId = 0
40- return ( component : FunctionComponent ) => {
41- if ( ! component ) {
42- throw new Error (
43- 'Overmind - You have to the Overmind hook the component reference, for debugging purposes'
44- )
45- }
46- const name = component . name || component . displayName
40+ const {
41+ ReactCurrentOwner,
42+ } = __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
43+ const useCurrentComponent = ( ) => {
44+ return ReactCurrentOwner . current . elementType
45+ }
46+
47+ return ( ) => {
48+ const component = useCurrentComponent ( )
49+ const name = component . name
4750 component . __componentId =
4851 typeof component . __componentId === 'undefined'
4952 ? nextComponentId ++
You can’t perform that action at this time.
0 commit comments