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

[Bug]: Incorrect type for present in Bottom Sheet Modal methods #2023

Closed
dwnste opened this issue Nov 4, 2024 · 4 comments
Closed

[Bug]: Incorrect type for present in Bottom Sheet Modal methods #2023

dwnste opened this issue Nov 4, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@dwnste
Copy link

dwnste commented Nov 4, 2024

Version

v5

Reanimated Version

v3

Gesture Handler Version

v2

Platforms

iOS, Android, Web

What happened?

According to the doc, the type should be any. But in this commit any was changed to never everywhere.

Types were not correctly resolved in the snack.

Reproduction steps

  • Pass data of any type to present method

Reproduction sample

https://snack.expo.dev/@dwnste/reproducing-issue

Relevant log output

No response

@dwnste dwnste added the bug Something isn't working label Nov 4, 2024
@omkarmoghe
Copy link

omkarmoghe commented Nov 10, 2024

Found this issue because I had the same question! I was looking at the map app example code, and was curious how this worked with type never? Also thought it should be any so that you can present the modal with arbitrary data, is there another way to achieve this?

https://github.com/gorhom/react-native-bottom-sheet/blob/master/example/src/screens/integrations/map/MapExample.tsx#L63

@maximpostnikov
Copy link
Contributor

If you don't want to wait for PR #2029, an alternative is to add a custom type to the project and use it as follows:

type BottomSheetModalWithData<T = any> = Omit<BottomSheetModal, 'present'> & { present: (data?: T) => void }
const alertModalPrimaryRef = useRef<BottomSheetModalWithData<AlertModalContentProps>>(null)

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

@L-Weisz
Copy link

L-Weisz commented Nov 12, 2024

I also have this issue
I had created a discussion here #2005
I just ignored the error for now

@gorhom
Copy link
Owner

gorhom commented Nov 17, 2024

it should be fixed in latest release , thanks to @maximpostnikov PR 🙌

@gorhom gorhom closed this as completed Nov 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants