Skip to content

Commit

Permalink
Merge pull request #29 from wdimmit/fix_withModal_Props
Browse files Browse the repository at this point in the history
Fix typechecking of wrapped components
  • Loading branch information
CharlesMangwa committed Sep 26, 2020
2 parents f18faf7 + d29c883 commit c1a55ff
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/withModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ import { invariant } from '../utils'
* @see https://colorfy-software.gitbook.io/react-native-modalfy/api/withmodal
*/
const withModal = <P extends ModalfyParams, Props extends object>(
Component: React.ComponentClass<ModalProp<P, Props>>,
Component: React.ComponentClass<Props>,
) => {
const displayName = Component.displayName || Component.name

class WithModalComponent extends React.Component<
Omit<Props, keyof ModalProp<P, Props>>
Omit<Props, keyof ModalProp<P, {}>>
> {
static displayName = `withModal(${displayName})`
static readonly WrappedComponent = Component
Expand All @@ -36,7 +36,6 @@ const withModal = <P extends ModalfyParams, Props extends object>(
`You should not use ${displayName} outside a <ModalProvider>`,
)
return (
// @ts-ignore
<Component
{...(this.props as Props)}
modal={{
Expand All @@ -54,7 +53,6 @@ const withModal = <P extends ModalfyParams, Props extends object>(
}
}

// @ts-ignore
return hoistStatics(WithModalComponent, Component)
}

Expand Down

0 comments on commit c1a55ff

Please sign in to comment.