区分React propTypes

时间:2017-09-05 05:14:17

标签: reactjs react-redux

显然,我需要删除ESLint中的警告

'campaignTypesResult' is missing in props validation      react/prop-types
'campaignTypesResult.map' is missing in props validation  react/prop-types
'statusesResult' is missing in props validation           react/prop-types
'statusesResult.map' is missing in props validation       react/prop-types
'campaignsActions' is missing in props validation                 react/prop-types
'campaignsActions.createCampaign' is missing in props validation  react/prop-types

campaignTypesResultstatusesResult是在react-redux中初始化的数组。

campaignsActions是react-redux中广告系列的操作。

我认为campaignTypesResultpropType.arraycampaignsActions propType.function

每种方法的正确验证是什么?

1 个答案:

答案 0 :(得分:0)

知道了,似乎动作是一个'对象',我的初始状态是'数组'。将操作作为“函数”在控制台中写入错误,指出操作确实是“对象”。

AddCampaignPage.propTypes = {
    statusesActions: PropTypes.object,
    campaignTypesActions: PropTypes.object,
    campaignsActions: PropTypes.object,
    campaignTypesResult: PropTypes.array,
    statusesResult: PropTypes.array
};