我的组件是通过class xxx extends创建的,但是我看了一些用redux创建的组件写法不一样,请问有办法转换一下吗?
class Login extends React.Component {
constructor() {
super();
this.state = {};
};
render() {
const {getFieldDecorator} = this.props.form;
return (
);
}
}
上面是我的代码,我想转换成下面的格式,因为要做页面跳转登录验证
const LoginPage = ({ history }) => (
<div>
<h1>Login Page</h1>
<p>
For this example application, we cannot visit <Link to="/app">/app</Link> until we are logged in.
Clicking the "Login" button will simulate a login by setting Redux state.
</p>
<button onClick={() => {
login().then(() => {
history.push('/app')
})
}}>Login</button>
</div>
)
下面是无状态的
React
组件,和Redux
没关系。如果你的组件实际上没用到生命周期函数的话,可以直接下面这样,参数就是
props
。使用方法同其他组件
http://www.jianshu.com/p/6356...
https://facebook.github.io/re...