React$Node 未定义

React$Node is undefined

我创建了新的 RN 项目。这个警告显示了。 我在这个项目中使用 Flow 和 eslint。我知道 React$Node 是什么意思。但我不知道为什么会出现这个警告。因为我觉得React已经定义好了。

这是我的.eslintrc.js

module.exports = {
  parser: 'babel-eslint',
  extends: ['airbnb', 'prettier', 'prettier/react', 'prettier/flowtype'],
  plugins: ['react', 'flowtype', 'jsx-a11y', 'import', 'react-native'],
  rules: {
    'react/jsx-filename-extension': [1, {extensions: ['.js', '.jsx']}],
    'react/prefer-stateless-function': [2, {ignorePureComponents: true}],
    'react/forbid-prop-types': [0, {forbid: []}],
    'import/extensions': [1, 'never', {svg: 'always', json: 'always'}],
    'import/no-extraneous-dependencies': [
      'error',
      {
        devDependencies: true,
        optionalDependencies: false,
        peerDependencies: false,
      },
    ],
    semi: ['error', 'never'],
  },
  env: {
    jest: true,
    browser: true,
  },
}

我将其添加到扩展中。 "plugin:flowtype/recommended"。所以它有效!

module.exports = {
  parser: 'babel-eslint',
  extends: [
    'airbnb',
    'prettier',
    'prettier/react',
    'prettier/flowtype',
    'plugin:flowtype/recommended',
  ],
  plugins: ['react', 'flowtype', 'jsx-a11y', 'import', 'react-native'],
  rules: {
    'react/jsx-filename-extension': [1, {extensions: ['.js', '.jsx']}],
    'react/prefer-stateless-function': [2, {ignorePureComponents: true}],
    'react/forbid-prop-types': [0, {forbid: []}],
    'import/extensions': [1, 'never', {svg: 'always', json: 'always'}],
    'import/no-extraneous-dependencies': [
      'error',
      {
        devDependencies: true,
        optionalDependencies: false,
        peerDependencies: false,
      },
    ],
    semi: ['error', 'never'],
  },
  env: {
    jest: true,
    browser: true,
  },
}


Recommended Configuration

使用时出现同样的错误

const TProps = {
    children: React$Node
}

而不是

type TProps = {
    children: React$Node
}