react-atom icon indicating copy to clipboard operation
react-atom copied to clipboard

HOC for use with non hook components

Open RedHatter opened this issue 6 years ago • 1 comments

Having a code base that has both hook based and class based components is common. It would be useful for react-atom to provide a HOC for these components. Something simple like the following should work.

const connect = (mapStateToProps, store) => Component => props => {
  const stateProps = mapStateToProps(useAtom(store))
  return <Component {...stateProps} {...props} />
}

RedHatter avatar Feb 28 '19 19:02 RedHatter

@RedHatter , I'm not opposed to that. Feel free to make a PR if you like. I need to add a contributing doc, but in short: please include tests and use npm run git:commit when ready to commit.

Otherwise, I'll get around to this when I have time.

derrickbeining avatar Mar 02 '19 18:03 derrickbeining