我想实现多步登录,类似于懈怠(它首先要求的域名,然后电子邮件,以及后来的密码)的反应,react-当地人。如何实现多步登录中发生反应或反应本地
我想知道什么是做到这一点的最佳做法?
我应该使用像ReactNavigation https://github.com/react-community/react-navigation路由器/导航解决方案?
我想实现多步登录,类似于懈怠(它首先要求的域名,然后电子邮件,以及后来的密码)的反应,react-当地人。如何实现多步登录中发生反应或反应本地
我想知道什么是做到这一点的最佳做法?
我应该使用像ReactNavigation https://github.com/react-community/react-navigation路由器/导航解决方案?
这就是做了,肯定的一种方式。我会做的方式是一种单组分:
class LoginComponent extends React.Component {
constructor(props) {
super(props);
this.state = { stage: 0 };
}
onDomainSubmit(data) {
this.props.getDomain(data.domain).then((domain) => {
this.setState({ domain, stage: 1 });
});
}
render() {
const { stage, domain } = this.state;
if (stage === 0) {
return <GetDomainForm onSubmit={ this.onDomainSubmit }... />;
} else if (stage === 1) {
return <LoginToDomainForm domain={ domain }... />;
}
}
}
getDomain
是对已经通过react-redux
的connect
注入到组件中的作用创造者 - 虽然这是没有必要的。
有头痛的这种方式,你需要的一切都包含在一个组件内。
你为什么不链中的国家责任,以显示你想要的领域?每次用户点击“下一个”,状态就会进一步移动。这样你就不会依赖用户可以欺骗的路线。 – MVCDS