在组件上使用扩展运算符时,Eslint道具类型被禁用

时间:2018-12-05 11:03:13

标签: react-native eslint react-proptypes

当我在组件内部使用扩展运算符时,eslint道具类型不会给我任何错误;

示例:

  • 这没有给我一个错误:

`

const { status } = props //status not have an error
let customProps = null;
if (status === 1) customProps = { style: { flex: 0.2 } };
else if (status === 2) customProps = { style: { flex: 0.4 } };

if (!customProps) return null;

return (
  <View {...customProps}>
  </View>
);

`

  • 这给我一个错误:

`

const { status } = props //status have an error
let customProps = null;
if (status === 1) customProps = { style: { flex: 0.2 } };
else if (status === 2) customProps = { style: { flex: 0.4 } };

if (!customProps) return null;

return (
  <View>
  </View>
);

`

0 个答案:

没有答案