user6536559
user6536559

Reputation:

How do I access a prop passed to TabNavigator within tab screen?

I have a tabnavigator like so

var TabNavigation = createBottomTabNavigator({
    NearbyScreen: { 
        screen: Nearby
    },
    FindScreen:{
        screen: LandmarkNavigation
    },
    NotificationScreen:{
        screen: Notifications
    },
    MyProfile:{
        screen: MyProfile
    }
})

that is rendered in the component

render() {
        //console.log(this.props);
        var nearbyLocations = this.props.locationsNearby;
        return(
            <TabNavigation thisThing="thisThingValue" />
        )
    }

How do I access the value of the prop I passed on inside one of it's tabs?

Upvotes: 1

Views: 1245

Answers (2)

user6536559
user6536559

Reputation:

I solved it with screenProps:

return(
            <TabNavigation screenProps={thing} />
        )

Which made it accessible in the navigator tab view via this.props.screenProps

Upvotes: 1

Bruno Mazzardo
Bruno Mazzardo

Reputation: 1586

Try accessing through here this.props.navigation.state.params.thisThing

Upvotes: 0

Related Questions