0

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/components/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?

Blanker
  • 51
  • 1
  • 4
  • 1
    Not an answer, but "It's a reserved word *in* strict mode." Not, "it's reserved *to* strict mode." – pushkin Jan 10 '18 at 05:33

1 Answers1

4

You want the static outside of the render method, not within it

   static navigationOptions = { header: null }

   render() {
      const { navigate } = this.props.navigation
      ...
   }
aqwert
  • 10,559
  • 2
  • 41
  • 61