frontend-hamroun 1.2.5 → 1.2.6

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.
package/dist/context.d.ts CHANGED
@@ -1,13 +1,12 @@
1
1
  export interface Context<T> {
2
2
  Provider: (props: {
3
3
  value: T;
4
- children?: any;
4
+ children: any;
5
5
  }) => any;
6
6
  Consumer: (props: {
7
7
  children: (value: T) => any;
8
8
  }) => any;
9
- _id: symbol;
10
- useSelector: <S>(selector: (state: T) => S) => S;
9
+ _currentValue: T;
11
10
  }
12
11
  export declare function createContext<T>(defaultValue: T): Context<T>;
13
- export declare function useContext<T>(context: any): T;
12
+ export declare function useContext<T>(context: Context<T>): T;
package/dist/context.js CHANGED
@@ -2,19 +2,17 @@ const contexts = new Map();
2
2
  let currentRender = null;
3
3
  export function createContext(defaultValue) {
4
4
  const context = {
5
- Provider: ({ value, children }) => {
5
+ _currentValue: defaultValue,
6
+ Provider: function Provider({ value, children }) {
7
+ context._currentValue = value;
6
8
  return children;
7
9
  },
8
- Consumer: ({ children }) => {
9
- return children(defaultValue);
10
- },
11
- _id: Symbol(),
12
- useSelector: (selector) => {
13
- return selector(defaultValue);
10
+ Consumer: function Consumer({ children }) {
11
+ return children(context._currentValue);
14
12
  }
15
13
  };
16
14
  return context;
17
15
  }
18
16
  export function useContext(context) {
19
- return context;
17
+ return context._currentValue;
20
18
  }