最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Static is a reserved keyword for strict mode - Stack Overflow

programmeradmin2浏览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/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
Add a ment  | 

1 Answer 1

Reset to default 4

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

   static navigationOptions = { header: null }

   render() {
      const { navigate } = this.props.navigation
      ...
   }
发布评论

评论列表(0)

  1. 暂无评论