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]: Infinite Re-rendering with Function-Based Content in BottomSheetModal #2106

Open
sanbondeveloper opened this issue Jan 6, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@sanbondeveloper
Copy link

Version

v5

Reanimated Version

v3

Gesture Handler Version

v2

Platforms

iOS, Android, Web

What happened?

First of all, I'm curious about the reason for changing the method of rendering the content of BottomSheetModal in version 5.

  • Before v5
{typeof Content === 'function' ? Content({ data }) : Content}
  • v5
{typeof Content === 'function' ? <Content data={data} /> : Content}

In v5, the method of rendering Content is causing infinite re-rendering when Content is in the form of a function. Therefore, I am using it with the following modifications.

diff --git a/node_modules/@gorhom/bottom-sheet/src/components/bottomSheetModal/BottomSheetModal.tsx b/node_modules/@gorhom/bottom-sheet/src/components/bottomSheetModal/BottomSheetModal.tsx
index 53ce110..13bfb04 100644
--- a/node_modules/@gorhom/bottom-sheet/src/components/bottomSheetModal/BottomSheetModal.tsx
+++ b/node_modules/@gorhom/bottom-sheet/src/components/bottomSheetModal/BottomSheetModal.tsx
@@ -457,7 +457,7 @@ function BottomSheetModalComponent<T = any>(
           onAnimate={handleBottomSheetOnAnimate}
           $modal={true}
         >
-          {typeof Content === 'function' ? <Content data={data} /> : Content}
+          {typeof Content === 'function' ? Content({ data }) : Content}
         </BottomSheet>
       </ContainerComponent>
     </Portal>

Reproduction steps

  • Pass the Content of BottomSheetModal as a function

Reproduction sample

https://snack.expo.dev/@gorhom/bottom-sheet---issue-reproduction-template

Relevant log output

No response

@sanbondeveloper sanbondeveloper added the bug Something isn't working label Jan 6, 2025
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

1 participant