小编Ann*_*her的帖子

如何修复“eslint-disable-next-line React/no-unstable-nested-components”

我的反应本机打字稿项目中有以下代码片段。

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

import DropDownPicker from 'react-native-dropdown-picker';

const Dropdown = () =>{
  <DropDownPicker
    ArrowDownIconComponent={() => ( // this is the section I getting the error message
      <MaterialCommunityIcons
        name="home-outline"
        size={50}
        color={theme.colors.text}
      />
    )}
  />
}
Run Code Online (Sandbox Code Playgroud)

由于 es-lint,它给出以下错误消息:

错误信息:

在父组件“DropDown”外部声明此组件或将其记忆化。如果你想允许在 props 中创建组件,请将 allowedAsProps 选项设置为 true.eslintreact/no-unstable-nested-components

错误图像:在此处输入图像描述

请问我可以知道如何修复上述错误吗?

react-native typescript-eslint

8
推荐指数
1
解决办法
1万
查看次数

标签 统计

react-native ×1

typescript-eslint ×1