简体   繁体   中英

Parsing error: Unexpected token for react native example code

Why do I get the parsing error

Parsing error: Unexpected token Props (null)

for this react native app example code? I am using the standardJS linter.

import React, { Component } from 'react';
import {
  Text,
  View
} from 'react-native';

type Props = {}; // <-- What is wrong with that?
export default class App extends Component<Props> {
  render() {
    return (
      <View>
        <Text>
          Welcome to React Native!
        </Text>
      </View>
    );
  }
}

Unless there is a good reason why you want to send the Props, you dont need that. Just remove it and keep 'Component {}'

Also, it could be that you need to use static instead of type. If you are copying this from another place, they are maybe using babel and another module. This is the first time I have seen someone write this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM