繁体   English   中英

解析错误:反应本机示例代码出现意外令牌

[英]Parsing error: Unexpected token for react native example code

为什么会出现解析错误

Parsing error: Unexpected token Props (null)

为此反应本机应用程序示例代码? 我正在使用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>
    );
  }
}

除非有充分的理由要发送道具,否则就不需要。 只需将其删除并保留“ Component {}”即可

同样,可能是您需要使用静态而不是类型。 如果要从另一个地方复制此文件,则他们可能正在使用babel和另一个模块。 这是我第一次看到有人写这篇文章。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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