I'm trying to declare a static variable in ReactNative but I cannot seem to get it work as I get this error message:
SyntaxError: /Users/vikaton/Desktop/iComeUp/src/ponents/LoginForm.js: static is a reserved word in strict mode (74:4)
9:37:20 PM: 72 |
9:37:20 PM: 73 | render() {
9:37:20 PM: > 74 | static navigationOptions = {
9:37:20 PM: | ^
9:37:20 PM: 75 | header: null
9:37:20 PM: 76 | };
9:37:20 PM: 77 | const { navigate } = this.props.navigation // fontFamily: 'heiti TC'
I added 'use strict';
at the top of my code but I still get the error message.
Any pointers?
I'm trying to declare a static variable in ReactNative but I cannot seem to get it work as I get this error message:
SyntaxError: /Users/vikaton/Desktop/iComeUp/src/ponents/LoginForm.js: static is a reserved word in strict mode (74:4)
9:37:20 PM: 72 |
9:37:20 PM: 73 | render() {
9:37:20 PM: > 74 | static navigationOptions = {
9:37:20 PM: | ^
9:37:20 PM: 75 | header: null
9:37:20 PM: 76 | };
9:37:20 PM: 77 | const { navigate } = this.props.navigation // fontFamily: 'heiti TC'
I added 'use strict';
at the top of my code but I still get the error message.
Any pointers?
Share asked Jan 10, 2018 at 5:31 BlankerBlanker 511 silver badge4 bronze badges 1- 1 Not an answer, but "It's a reserved word in strict mode." Not, "it's reserved to strict mode." – pushkin Commented Jan 10, 2018 at 5:33
1 Answer
Reset to default 4You want the static outside of the render
method, not within it
static navigationOptions = { header: null }
render() {
const { navigate } = this.props.navigation
...
}