【发布时间】:2019-07-12 23:34:31
【问题描述】:
我在meteorJS 中使用了react-router-dom。我在创建帐户后尝试重定向。现在帐户已成功创建,但重定向不起作用。
我也尝试在成功创建帐户时添加 setState。它也不起作用。
handleSubmit(event) {
event.preventDefault();
Accounts.createUser(
{
username: this.state.mobile,
password: "123"
},
function(err) {
if (err) {
console.log("err", err);
} else {
console.log("account created");
this.setState({
redirect: true
});
return <Redirect to="/" />;
}
}
);
}
此消息显示在控制台中
Exception in delivering result of invoking 'createUser': TypeError: this.setState is not a function
【问题讨论】:
标签: reactjs meteor react-router react-router-dom