floppy-disk 2.11.1-alpha.2 → 2.11.1-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
2
|
export declare const withContext: <T>(initFn: () => T) => readonly [({ children, onInitialize, }: {
|
|
3
3
|
children: ReactNode;
|
|
4
4
|
onInitialize?: ((value: T) => void) | undefined;
|
|
5
|
-
}) =>
|
|
5
|
+
}) => import("react").FunctionComponentElement<import("react").ProviderProps<T | null>>, () => T | null];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createContext, createElement, useContext, useState } from 'react';
|
|
2
2
|
export const withContext = (initFn) => {
|
|
3
3
|
const Context = createContext(null);
|
|
4
4
|
const Provider = ({ children, onInitialize, }) => {
|
|
@@ -7,7 +7,7 @@ export const withContext = (initFn) => {
|
|
|
7
7
|
onInitialize && onInitialize(store);
|
|
8
8
|
return store;
|
|
9
9
|
});
|
|
10
|
-
return
|
|
10
|
+
return createElement(Context.Provider, { value, children });
|
|
11
11
|
};
|
|
12
12
|
const useCurrentContext = () => useContext(Context);
|
|
13
13
|
return [Provider, useCurrentContext];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
2
|
export declare const withContext: <T>(initFn: () => T) => readonly [({ children, onInitialize, }: {
|
|
3
3
|
children: ReactNode;
|
|
4
4
|
onInitialize?: ((value: T) => void) | undefined;
|
|
5
|
-
}) =>
|
|
5
|
+
}) => import("react").FunctionComponentElement<import("react").ProviderProps<T | null>>, () => T | null];
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.withContext = void 0;
|
|
4
|
-
const
|
|
5
|
-
const react_1 = tslib_1.__importStar(require("react"));
|
|
4
|
+
const react_1 = require("react");
|
|
6
5
|
const withContext = (initFn) => {
|
|
7
6
|
const Context = (0, react_1.createContext)(null);
|
|
8
7
|
const Provider = ({ children, onInitialize, }) => {
|
|
@@ -11,7 +10,7 @@ const withContext = (initFn) => {
|
|
|
11
10
|
onInitialize && onInitialize(store);
|
|
12
11
|
return store;
|
|
13
12
|
});
|
|
14
|
-
return react_1.
|
|
13
|
+
return (0, react_1.createElement)(Context.Provider, { value, children });
|
|
15
14
|
};
|
|
16
15
|
const useCurrentContext = () => (0, react_1.useContext)(Context);
|
|
17
16
|
return [Provider, useCurrentContext];
|