Skip to content

Instantly share code, notes, and snippets.

@mjhassan
Created October 27, 2020 03:04
Show Gist options
  • Select an option

  • Save mjhassan/aebd9111182b7831cac9af2d144cf934 to your computer and use it in GitHub Desktop.

Select an option

Save mjhassan/aebd9111182b7831cac9af2d144cf934 to your computer and use it in GitHub Desktop.
Hook usage in class
function withHook(Component) {
return function WrappedComponent(props) {
const useReducer = React.useReducer(reducer, initialState);
return <Component {...props} useReducer={useReducer}/>
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment