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

How to access props inside rightTitle/onRight static function? #2308

Closed
ptquang86 opened this issue Aug 31, 2017 · 2 comments
Closed

How to access props inside rightTitle/onRight static function? #2308

ptquang86 opened this issue Aug 31, 2017 · 2 comments

Comments

@ptquang86
Copy link

Version

  • react-native-router-flux ^4.0.0-beta.21
  • react-native ^0.44.3

Expected behaviour

// these are not working
// this.rightTitle = this.rightTitle.bind(this);
// rightTitle = rightTitle.bind(this);

static rightTitle = () => {
        const { shareForm: { ui: { fetching } } } = this.props;
        if (fetching) {
            return <ActivityIndicator color={colors.greeny_blue}/>
        } else {
            return <Headline style={styles.navButton}>
                <Message id='ShareForm_Details_CTA' />
            </Headline>
        }
    }

Actual behaviour

undefined is not an object '_this2.props.shareForm'

@ptquang86 ptquang86 changed the title How to access props inside onRight static function? How to access props inside rightTitle/onRight static function? Aug 31, 2017
@aksonov
Copy link
Owner

aksonov commented Sep 1, 2017

It is about javascript programming... Static function doesn't have this, just props access from function params!

@aksonov aksonov closed this as completed Sep 1, 2017
@ptquang86
Copy link
Author

i tried
static rightTitle = (params) => { ... }
but params is not a props/state

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants