۱۳۹۶ مهر ۸, شنبه

javascript - this.props.dispatch().then is not a function

[ad_1]



I am trying to do something as soon as a dispatch action finishes, and a similar question led me to try to use .then. I get an error that it doesn't exist, this.props.dispatch().then is not a function:



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: "fake@fake.com")
.then((response) =>
browserHistory.push(self.props.destination_url);
)



We also tried the way you do something when this.setState finishes, passing it as a second arg:



this.props.dispatch(type: 'LOG_IN', payload: "fake@fake.com", reroute)


neither worked. The this.props.dispatch seems to come for free with using the @connect decorator. How can I run something only after this redux store is updated with the "LOG_IN" action? Thank you




[ad_2]

لینک منبع

هیچ نظری موجود نیست:

پست کردن نظر