dispatch
アクションが終了するとすぐに何かをしようとしています。同様の質問で.then
を使用しようとしました。私はthis.props.dispatch().then is not a function
、それが存在しないというエラーが表示されます。this.props.dispatch()。次に関数ではありません
export function unpackStore(redux_store, namespace) {
// namespace is determined by what name you gave each reducer in combineReducers; client/reducers/index.js
let final_props = {};
let KEYS = Object.keys(redux_store[namespace]);
for (let key of KEYS) {
final_props[key] = redux_store[namespace][key];
}
return final_props;
}
export function basicUnpackStoreClosure(namespace) {
return function(store) {
let props = unpackStore(store, namespace);
return props;
}
}
@connect(basicUnpackStoreClosure('login_info'))
export default class LoginPage extends MyComponent {
constructor(props) {
let custom_methods = [
'handleLoginOrRegisterToggle',
'handleOnKeyDownInInputs',
'onLoginSubmit',
'onRegisterSubmit',
]
super(props, custom_methods);
this.state = {
mode: 'login',
email: '',
password: '',
password_confirm: ''
};
if (props.mode == 'register') {
this.state.mode = 'register';
}
}
onLoginSubmit() {
let self = this;
let reroute = function() {
browserHistory.push(self.props.destination_url);
}
this.props.dispatch({type: 'LOG_IN', payload: "[email protected]"})
.then((response) => {
browserHistory.push(self.props.destination_url);
})
}
我々はまた、第二引数として渡す、this.setState
仕上げあなたが何かをする方法を試してみました:働い
this.props.dispatch({type: 'LOG_IN', payload: "[email protected]"}, reroute)
でもありません。 this.props.dispatch
は、@connect
デコレータを使用して無料で来ているようです。このreduxストアが "LOG_IN"アクションで更新された後でのみ、何かを実行できますか?ありがとう
あなたの質問は、ディスパッチコールから「約束」を得る方法です。 – IzumiSy