var
var

Reputation: 119

Passing the navigation object down the nested react component

My react component hierarchy looks like

StackNavigation
  - MainScreen
      - List
          - Row
              - Button

My usecase involves go to a new screen on click of the button. My main screen receives react-navigation's navigation props. How do I pass it down to my button in a sane manner.

Upvotes: 0

Views: 169

Answers (1)

Igor Shaulov
Igor Shaulov

Reputation: 58

You'd better pass a callback to your button through all the hierarchy and call it when button is pressed. Afterwards when you know which button is pressed (on which row) you can navigate to necessary screen from your MainScreen.

Upvotes: 1

Related Questions