我使用react-redux-forms及以下quick start過去了,我創建反應的組分:反應 - 終極版形式 - 調度不道具
該類containts店確定指標和Provider
import React from 'react';
import { Provider } from 'react-redux';
import { createStore,applyMiddleware } from 'redux';
import { combineForms } from 'react-redux-form';
import RecordForm from './components/RecordForm.jsx'
const initRecord= {
name: '',
SUKL: '',
ATC: ''
};
const store = createStore(combineForms({
record: initRecord
}));
@translate(['record'], { wait: true })
export default class App extends React.Component {
constructor(props){
super(props);
}
render() {
const { t }= this.props;
return (
<div>
<div className="row">
<div className="row header">
<h1>
{t('record.NewRecord')}
</h1>
</div>
<div className="row">
<Provider store={ store }>
<RecordForm />
</Provider>
</div>
</div>
</div>
);
}
這是形式的文件:
import React from 'react';
import { connect } from 'react-redux';
import { Control, Form } from 'react-redux-form';
export default class RecordForm extends React.Component {
constructor(props){
super(props);
}
handleSubmit(record) {
const { dispatch } = this.props;
///dispatch is undefined !!!!!!!
}
render() {
return (
<div>
<Form model="record" onSubmit={(record) => this.handleSubmit(record)}>
<Control.text model="record.name" />
<button type="submit">
OK!
</button>
</Form>
</div>
);
}
}
當我到handleSumbit部分 - 調度未定義。當我調試這個時,即使在RecordForm的構造器中,也有o派發道具或任何相關的東西來形成。我應該添加一些像connect()這樣的註釋嗎?我錯過了什麼?