Coder Social home page Coder Social logo

Comments (9)

nkbhasker avatar nkbhasker commented on September 2, 2024 2

This is how I have done it. It covers both dynamic content and react navigation bottom tab.

  • Create bottom sheet provider

  • Create main stack navigator(somehow bottom sheet doesn't work if tab navigator is not wrapped in a stack navigator)

  • Create tab navigator and wrap it inside the bottom sheet provider

Have created a repository for reference: https://github.com/nkbhasker/react-navigation-bottomsheet

from react-native-reanimated-bottom-sheet.

iamolegga avatar iamolegga commented on September 2, 2024

@roshangm1 I use something like that:

// define renderContent func with useCallback hook and don't forget to set dependencies
const renderContent = useCallback(() => <SomeJSX />, [...dependenciesForSomeJSX])

<BottomSheet
  // BottomSheet will get new `renderContent` prop and rerender if dependenciesForSomeJSX will change
  renderContent={renderContent}
/>

from react-native-reanimated-bottom-sheet.

iamolegga avatar iamolegga commented on September 2, 2024

@osdnk I think this issue can be closed

from react-native-reanimated-bottom-sheet.

satya164 avatar satya164 commented on September 2, 2024

useCallback is unnecessary here and won't change anything because the BottomSheet component is not a PureComponent

from react-native-reanimated-bottom-sheet.

iamolegga avatar iamolegga commented on September 2, 2024

all right, than you can use wrapper like:

const PureBottomSheet = React.memo((props) => <BottomSheet {...props} />)

from react-native-reanimated-bottom-sheet.

satya164 avatar satya164 commented on September 2, 2024

It's very likely that render will be called when you're changing something. If you're not changing something and your component is being re-rendered, it's probably good idea to add memo higher on the tree

from react-native-reanimated-bottom-sheet.

iamolegga avatar iamolegga commented on September 2, 2024

Agree, but if parent component render something besides BottomSheet and it's content, I would recommend to make a pure wrapper if one care about performance

from react-native-reanimated-bottom-sheet.

arberkryeziu avatar arberkryeziu commented on September 2, 2024

can someone share a "best-practice" here on how to dynamically render content on BottomSheet ?

@satya164 Im using navigation v5. Would you recommend to place a global BottomSheet (with dynamic content) beside Stack.Navigator ?

from react-native-reanimated-bottom-sheet.

TriPSs avatar TriPSs commented on September 2, 2024

@nkbhasker i'm trying your solution but i'm having issues with the fact that onOpenStart and onCloseEnd are not being called, i'm also unable to close the bottom sheet after it opened. Did you also encounter these issues?

Edit: I figured it out, the amount of snap points need to stay the same, I had default 2 snap points and updated it to 3, now I changed the default to 3 and everything works nice.

from react-native-reanimated-bottom-sheet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.