Skip to content

Instantly share code, notes, and snippets.

@mattpocock
Created May 28, 2019 18:54
Show Gist options
  • Select an option

  • Save mattpocock/3b1dedd660baa7e2e936e6b0e4add0cb to your computer and use it in GitHub Desktop.

Select an option

Save mattpocock/3b1dedd660baa7e2e936e6b0e4add0cb to your computer and use it in GitHub Desktop.
withLogic.jsx - a HOC that allows you to watch props and take actions outside of the component render area. Ideal for adding some hook logic in to classes.
import React from 'react'
const withLogic = useLogic => Component => props => {
const propsToPass = useLogic(props) || {}
return <Component {...props} {...propsToPass} />
}
export default withLogic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment