解析错误:反应本机示例代码的意外标记



为什么我会收到解析错误

Parsing error: Unexpected token Props (null)

对于这个反应原生应用程序示例代码?我正在使用标准的JS棉绒。

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>
    );
  }
}

除非有充分的理由要发送道具,否则您不需要它。只需将其删除并保留"组件{}">

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

最新更新