Last active
August 23, 2023 12:41
-
-
Save EmmanuelObua/c78e5139fb90b54975dbd169d37dda84 to your computer and use it in GitHub Desktop.
This file contains 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, { useContext } from 'react'; | |
import { TaskConsumer } from './TaskContext'; | |
// This is a custom hook, a pattern where a reusable function is created that encapsulates common logic or state management, | |
// allowing the logic to be easily shared between components. | |
// It's as a higher-order component,a pattern where a component is wrapped in another component, | |
// allowing the inner component to inherit functionality from the outer component. | |
export function withTaskContext(Component) { | |
return function WrappedComponent(props) { | |
return ( | |
<TaskConsumer> | |
{taskContext => <Component {...props} taskContext={taskContext} />} | |
</TaskConsumer> | |
); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment