반응에서 기본 소품을 선언하는 올바른 방법은 무엇입니까? 그래서 redux를 사용하여 비동기 적으로 할당 된 소품의지도를 호출 할 때 정의되지 않은 오류가 발생하지 않도록하려면 어떻게해야합니까? 바로 다음 구문을 사용하면 렌더링 할 초기 호출에서 데이터가 정의되지 않았으므로 trans_filter를 할당 할 때 오류가 발생합니다. 여기Redux를 사용할 때 ReactJS 기본 소품을 선언하는 방법?
class ContainerComponent extends React.Component {
static defaultProps = {
searchProps: {
data: []
}
};
constructor(props) {
super(props);
}
render(){
let trans_filter = JSON.parse(JSON.stringify(this.props.searchProps.data));
}
}
const mapStateToProps = (state) => ({
searchProps: state.searchProps
});
export default connect(mapStateToProps, {getTransactionsAll})(ContainerComponent);
일 수 있습니다. http://stackoverflow.com/questions/38004703/set-default-props-for-a-react-component –
'연결'및 감속기 코드를 게시 할 수 있습니까? – lpan
해당 제안 사항이 없습니다. –