{"action":"closed","issue":{"url":"https://api.github.com/repos/react-community/react-navigation/issues/2025","repository_url":"https://api.github.com/repos/react-community/react-navigation","labels_url":"https://api.github.com/repos/react-community/react-navigation/issues/2025/labels{/name}","comments_url":"https://api.github.com/repos/react-community/react-navigation/issues/2025/comments","events_url":"https://api.github.com/repos/react-community/react-navigation/issues/2025/events","html_url":"https://github.com/react-community/react-navigation/issues/2025","id":239456748,"number":2025,"title":"How I can access screen propery passed by screen wrap container in navigationOptions create function","user":{"login":"oxape","id":8132919,"avatar_url":"https://avatars3.githubusercontent.com/u/8132919?v=4","gravatar_id":"","url":"https://api.github.com/users/oxape","html_url":"https://github.com/oxape","followers_url":"https://api.github.com/users/oxape/followers","following_url":"https://api.github.com/users/oxape/following{/other_user}","gists_url":"https://api.github.com/users/oxape/gists{/gist_id}","starred_url":"https://api.github.com/users/oxape/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oxape/subscriptions","organizations_url":"https://api.github.com/users/oxape/orgs","repos_url":"https://api.github.com/users/oxape/repos","events_url":"https://api.github.com/users/oxape/events{/privacy}","received_events_url":"https://api.github.com/users/oxape/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-06-29T12:05:27Z","updated_at":"2017-08-10T09:03:19Z","closed_at":"2017-08-10T09:03:19Z","body":"How I can access component property logout in navigationOptions create function. Can't access instance “this” in static variable.\r\n\r\n```\r\nconst mapStateToProps = (state, ownProps) => {\r\n    return state;\r\n};\r\n\r\nconst mapDispatchToProps = (dispatch, ownProps) => {\r\n    return {\r\n        logout: () => {\r\n            dispatch(logoutAction());\r\n        },\r\n        navigateInput: () => {\r\n            dispatch(NavigationActions.navigate({ routeName: 'Input' }));\r\n        },\r\n    }\r\n};\r\n\r\nconst ScanContainer = connect(\r\n    mapStateToProps,\r\n    mapDispatchToProps\r\n)(ScanPage);\r\n\r\nexport default ScanContainer\r\n```\r\nComponent\r\n```\r\nclass ScanPage extends Component {\r\n\r\n    static navigationOptions = (props) => {\r\n        console.log(props);\r\n        console.log(this.props);\r\n        return {\r\n            title: 'Scan',\r\n            headerRight: (\r\n                <Button title='logout' onPress={() => {console.log(props); console.log(this.props);}}/>\r\n            ),\r\n        }\r\n    }\r\n}\r\n```\r\nthis.props is undefined.\r\nMy Navigator\r\n```\r\nconst HomeNavigator = StackNavigator({\r\n    Scan: { screen: ScanContainer },\r\n    Input: { screen: InputContainer },\r\n});\r\n```\r\nAlthough I can use the following method. But I think it is not enough elegant.Exposed the actions to the component.\r\n```\r\n    static navigationOptions = ({ navigation }) => {\r\n        return {\r\n            title: 'scan',\r\n            headerRight: (\r\n                <Button title='logout' onPress={() => {navigation.dispatch(logoutAction());}}/>\r\n            ),\r\n        }\r\n    }\r\n```\r\n\r\nSimilar, How do I access this.state in navigationOptions.\r\n\r\n| software         | version\r\n| ---------------- | -------\r\n| react-navigation |  ^1.0.0-beta.11\r\n| react-native     |  0.44.2\r\n| node             |  6.2.0\r\n| npm or yarn      | npm 3.8.9 yarn 0.24.5\r\n"}}
{"actor":{"display_login":"oxape"}}