Open suttang opened 6 years ago
redux の connect も HOC なのでまとめると良さそう
connect
// Component // ================================================================== const BaseComponent: React.SFC<Props> = () => ( <div> <h1>Hello!!!!</h1> <Link to='/login'>Login</Link> </div> ) const connector = connect(() => ({}), () => ({})) const enhancer: HOC<Props, Props> = compose( connector, setDisplayName('Home'), pure ) // Redux connect // ================================================================== export default enhancer(BaseComponent)
const enhancer: HOC<Props, Props> = compose( connect(mapStateToProps, mapDispatchToProps), setDisplayName('Home'), pure )
のほうがシンプルか。
redux の
connect
も HOC なのでまとめると良さそう