Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add generic type for data modal #2029

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

maximpostnikov
Copy link

Motivation

This PR addresses an issue related to #2023.

It introduces the ability to explicitly define types for data passed through refs, ensuring strict typing for this data.

const alertModalPrimaryRef = useRef<BottomSheetModal<AlertModalContentProps>>(null);

const handleUpdatePress = () => {
  alertModalPrimaryRef.current?.present({
      type: 'success',
      test: true,  // Throws error because `test` isn't defined in `AlertModalContentProps`
    })
}

Additionally, it would be beneficial if the data passed through children could also be typed.

export type AlertModalContentProps = {
  type: 'success' | 'error'
}

...

<BottomSheetModal<AlertModalContentProps>
  name={name}
  ref={ref}>
  {({ data }) => (
    <BottomSheetView>
      {data && <AlertModalContent {...data} />}
    </BottomSheetView>
  )}
</BottomSheetModal>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant