Created
May 28, 2019 18:54
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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