【发布时间】:2019-09-24 16:55:57
【问题描述】:
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import PropType from 'prop-types';
import Counter from '../components/Counter';
import * as counterActions from '../store/modules/counter';
class CounterContainer extends Component {
handleIncrement = () => {
console.log('+');
const { CounterActions } = this.props;
CounterActions.increment();
}
handleDecrement = () => {
console.log('-');
const { CounterActions } = this.props;
CounterActions.decrement();
}
render() {
const { handleIncrement, handleDecrement } = this;
const { number } = this.props;
return (
<Counter
onIncrement={handleIncrement}
onDecrement={handleDecrement}
number={number}
/>
);
}
}
我正在使用 ESLint airbnb。 当我写上面的代码 ESLint
引发错误,道具验证中缺少“CounterActions”。并且道具验证中缺少“数字”
所以我加了
CounterContainer.propTypes = {
number: PropType.number,
CounterActions: PropType.func,
};
propType "number" 不是必需的,但没有对应的 defaultProps 声明。 propType "CounterActions" 不是必需的,但没有相应的 defaultProps 声明。
从现在开始我不知道如何更改它。 我正在尝试在遵循本教程的同时应用 ESLint。 怎么改?
【问题讨论】:
标签: reactjs react-native react-redux