2
我有以下的智能組件,我指定initialUpload
功能是必需的FUNC:行動最初是未定義
import React, { Component, PropTypes } from 'react';
import UploadForm from '../../components/UploadForm/UploadForm';
import HeaderSelection from '../../components/HeaderSelection/HeaderSelection';
import { initialUpload } from '../../redux/modules/Upload';
import { connect } from 'react-redux';
console.log(typeof initialUpload); //function
@connect((state) => {
return {
file: state.getIn(['upload', 'file'])
};
}, {
initialUpload
})
export default class Home extends Component {
static propTypes = {
initialUpload: PropTypes.func.isRequired
};
render() {
return (
<div>
<UploadForm handleFilesChange={this.props.initialUpload}/>
<HeaderSelection/>
</div>
);
}
}
但我得到的錯誤信息:
warning.js:36警告:失敗的道具類型:道具
initialUpload
爲 ,標記爲Connect(Home)
中的要求,但其值爲undefined
。
該函數被包裝在調度中,並向下傳遞組件層次結構,所以我對發生了什麼感到困惑。
哪個組件正在呼叫Home? – Aus