add provider config to baseWrapContext
This commit is contained in:
parent
a3db95395e
commit
b35ca2e9a3
@ -8,4 +8,6 @@ const App = () => {
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
export default wrapTestProvider(App)
|
export default wrapTestProvider(App, {props: {
|
||||||
|
chambers: 70
|
||||||
|
}})
|
||||||
|
@ -28,6 +28,7 @@ export const useTestContext = baseUseContext(Context)
|
|||||||
|
|
||||||
export const withTestContext = baseWithContext(Context, 'testContextProps')
|
export const withTestContext = baseWithContext(Context, 'testContextProps')
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
export const wrapTestProvider = baseContextWrap(TestContextProvider)
|
export const wrapTestProvider = baseContextWrap(TestContextProvider)
|
||||||
|
|
||||||
export default TestContextProvider
|
export default TestContextProvider
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "base-context-provider",
|
"name": "base-context-provider",
|
||||||
"version": "1.0.2",
|
"version": "1.0.2-a",
|
||||||
"description": "Made with create-react-library",
|
"description": "Made with create-react-library",
|
||||||
"author": "vuthpov",
|
"author": "vuthpov",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
@ -27,14 +27,19 @@ class BaseContextProvider<PROPS = {}, STATE = {}> extends React.Component<
|
|||||||
const contextReturn = this.getContextReturnValue()
|
const contextReturn = this.getContextReturnValue()
|
||||||
const Context = this.getContext()
|
const Context = this.getContext()
|
||||||
const { children } = this.props
|
const { children } = this.props
|
||||||
|
|
||||||
return <Context.Provider value={contextReturn}>{children}</Context.Provider>
|
return <Context.Provider value={contextReturn}>{children}</Context.Provider>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface ContextWrapConfig {
|
||||||
|
props: {
|
||||||
|
[index: string]: any
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const baseContextWrap = (Provider: any) => {
|
export const baseContextWrap = (Provider: any) => {
|
||||||
return (Component: any) => (props: any) => (
|
return (Component: any, config?: ContextWrapConfig) => (props: any) => (
|
||||||
<Provider children={<Component {...props} />} />
|
<Provider {...config} children={<Component {...props} />} />
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user