# `react-wrap-with`
Creates higher-order component (HOC) for wrapping component in another component. Also reduce code complexity for React Context by mixing components into a new component.
## Background
> This package targets React developers who build reusable components.
When using React Context or building reusable components, an intermediate component are often needed. This package will help reduce code complexity by wrapping as an intermediate component.
## How to use
The following samples assumes a theme is set for the whole component via React Context with corresponding provider component and a HOC function.
### Before
```tsx
import { createContext } from 'react';
const ThemeContext = createContext();
const ThemeProvider = ({ children }) => {children};
const withTheme = Component => props => (
);
export { ThemeProvider, withTheme };
```
### After
```tsx
import { createContext } from 'react';
import { wrapWith } from 'react-wrap-with';
const ThemeContext = createContext();
const ThemeProvider = ({ children }) => {children};
const withTheme = wrapWith(ThemeProvider);
export { ThemeProvider, withTheme };
```
### Extracting props
Let's assume a prop named `accent` need to be extracted and passed to the `` component in the following manner:
```ts
const ButtonWithTheme = withTheme(Button);
// `accent` with value of `"blue"` will be passed to ``, while `text` will be passed to `