-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fde8b3b
commit d25f368
Showing
4 changed files
with
14 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,22 @@ | ||
import React, { ReactElement, ComponentType, ReactNode } from 'react'; | ||
import React, { ReactElement, ComponentType } from 'react'; | ||
|
||
import useAlien, { ReduxModule, AlienResult } from './useAlien'; | ||
import useAlien, { AlienResult, AlienModule } from './useAlien'; | ||
|
||
interface WithAlienProps { | ||
children?: ReactNode; | ||
actions: AlienResult['actions']; | ||
} | ||
|
||
function WithAlien<P extends object>( | ||
Component: ComponentType<P>, | ||
getModule: () => Promise<ReduxModule>, | ||
alienModule: AlienModule, | ||
): ReactElement<P & WithAlienProps> | null { | ||
// it complains just beacause the function doesn't start with Capital case | ||
// so it thinks it not a React component | ||
// eslint-disable-next-line react-hooks/rules-of-hooks | ||
const alienResult = useAlien({ | ||
getModule, | ||
}); | ||
const alienResult = useAlien(alienModule); | ||
|
||
if (alienResult) { | ||
return <Component {...(alienResult as P)} />; | ||
} | ||
|
||
return null; | ||
// return <Component {...((alienResult && alienResult) as P)} />; | ||
// return typeof props.children === 'function' ? props.children() : props.children; | ||
} | ||
|
||
export default WithAlien; |