Day 3: Recompose

class MyComponent extends React.Component {
  constructor(props) {
    super(props)
    this.state = {}
  }  componentDidMount() {
  }  render() {
    return (...)
  }
}
const MyComponent = () => <p>Hello</p>

const Profile = ({ name }) => <p>Hello, {name}!</p>
const mapStateToProps = state => ({ name: 'Chai' })
const withData = connect(mapStateToProps)
const withButtonHandlers = withHandlers({
  onClick: () => e => {
    e.preventDefault()
    // DO SOMETHING
  }
})
const withRemoteData = lifecycle({
  componentDidMount() {
    // FETCH DATA AND DISPATCH
  }
}
export default compose(
  withData,
  withButtonHandlers,
  withRemoteData
)(Profile)
const combo = compose(
  withData,
  withButtonHandlers,
  withRemoteData
)export default combo(Profile)

สุดท้าย

Devahoy

Learn and share about technologies that power the world, read more at https://devahoy.com

Chai Phonbopit

Written by

[**MOVE TO MY OWN BLOG] I make web stuff with JavaScript (Node & React), Blogger at https://devahoy.com

Devahoy

Devahoy

Learn and share about technologies that power the world, read more at https://devahoy.com