From b35ca2e9a33e0395b2c237f35654fd45de0d85b0 Mon Sep 17 00:00:00 2001 From: Vut Pov Date: Wed, 15 Jul 2020 12:11:11 +0700 Subject: [PATCH] add provider config to baseWrapContext --- example/src/App.tsx | 4 +++- example/src/TestContext.ts | 1 + package.json | 2 +- src/index.tsx | 11 ++++++++--- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/example/src/App.tsx b/example/src/App.tsx index 1a404b2..748b43c 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -8,4 +8,6 @@ const App = () => { } -export default wrapTestProvider(App) +export default wrapTestProvider(App, {props: { + chambers: 70 +}}) diff --git a/example/src/TestContext.ts b/example/src/TestContext.ts index a2c54ee..87d9fb0 100644 --- a/example/src/TestContext.ts +++ b/example/src/TestContext.ts @@ -28,6 +28,7 @@ export const useTestContext = baseUseContext(Context) export const withTestContext = baseWithContext(Context, 'testContextProps') +// @ts-ignore export const wrapTestProvider = baseContextWrap(TestContextProvider) export default TestContextProvider diff --git a/package.json b/package.json index f5e8470..0836d10 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "base-context-provider", - "version": "1.0.2", + "version": "1.0.2-a", "description": "Made with create-react-library", "author": "vuthpov", "license": "MIT", diff --git a/src/index.tsx b/src/index.tsx index 02480ca..d2b7ea9 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -27,14 +27,19 @@ class BaseContextProvider extends React.Component< const contextReturn = this.getContextReturnValue() const Context = this.getContext() const { children } = this.props - return {children} } } +interface ContextWrapConfig { + props: { + [index: string]: any + } +} + export const baseContextWrap = (Provider: any) => { - return (Component: any) => (props: any) => ( - } /> + return (Component: any, config?: ContextWrapConfig) => (props: any) => ( + } /> ) }