N
N
Newbie Ivanovich2019-09-03 06:21:06
React Native
Newbie Ivanovich, 2019-09-03 06:21:06

How to pass a variable from a local state to navigationOptions?

How to pass value from local state to

static navigationOptions = ({ navigation }) => {
        
        return {
            title: `Значение которое нужно прокинуть`,
            headerLeft: <Icon
                name="angle-left"
                color="#FFF"
                size={30}
                style={{ marginLeft: 20 }}
                onPress={() => navigation.navigate('Test')} />
        };
    };

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Alexandrovich, 2019-09-03
@NovichokIvanovich

you need to put the value in the navigator for example

this.props.navigation.setParams({isHeaderShow: <true | false>});

and if necessary, get it and put it where you need it
static navigationOptions ({navigation}) => {
    return {
         headerVisible: navigation.state.params.isHeaderShow
    }
}

D
Dimka Reactive, 2019-09-03
@raoffonom

You need to use this.props.navigation.state
There is a detailed example in the dock

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question