File tree Expand file tree Collapse file tree 4 files changed +37
-4
lines changed Expand file tree Collapse file tree 4 files changed +37
-4
lines changed Original file line number Diff line number Diff line change 1
1
# Changelog
2
2
3
- ## 0.2.1 (_ 27 February 2021_ )
3
+
4
+ ## 0.2.2
5
+ _ 9 April 2021_
6
+
7
+ * TypeScript improvements: When providing a super context that accepts props, you will now get a type error if you don't provide any props
8
+
9
+ Example:
10
+ ``` tsx
11
+ // CounterContext.ts
12
+ const [counterContext, useCounter] = createSuperContext (({ initial }: CounterContextProps ) => {
13
+ ...
14
+ });
15
+
16
+ // App.tsx
17
+ // This is now a type error:
18
+ const App = () => <SuperContext contexts = { [counterContext ]} ></SuperContext >
19
+
20
+ // Correct usage (no errors):
21
+ const App = () => <SuperContext contexts = { [counterContext ({ initial: 10 })]} ></SuperContext >
22
+ ```
23
+
24
+ ## 0.2.1
25
+ _ 27 February 2021_
26
+
4
27
* Mark the ` interceptors ` feature as deprecated and link to wiki explaining why in docs and console warnings.
5
28
* Remove ` interceptors ` examples.
6
29
* Remove experimental warning from readme since API is now unlikely to change before version 1.0.0.
7
30
8
- ## 0.2.0 (_ 21 January 2021_ )
31
+ ## 0.2.0
32
+ _ 21 January 2021_
33
+
9
34
* New ` testValue ` option for contexts. This is the value returned by the super context hook in a test environment.
10
35
* New ` testEnvironment ` option for context. Can be used to override the ` NODE_ENV === "test" ` check to determine if running in a test environment.
11
36
Original file line number Diff line number Diff line change 9
9
" boilerplate"
10
10
],
11
11
"license" : " MIT" ,
12
- "version" : " 0.2.1 " ,
12
+ "version" : " 0.2.2 " ,
13
13
"repository" : {
14
14
"url" : " https://github.com/goransh/react-super-context"
15
15
},
Original file line number Diff line number Diff line change @@ -33,6 +33,14 @@ export interface CreateSuperContextOptions<T> {
33
33
}
34
34
35
35
// could maybe benefit from partial type argument inference: https://github.com/microsoft/TypeScript/issues/26242
36
+ export function createSuperContext < T > (
37
+ factory : ( ) => T ,
38
+ options ?: Partial < CreateSuperContextOptions < T > >
39
+ ) : [ ( ) => SuperContextDefinition < any , T > , ( ) => T ] ;
40
+ export function createSuperContext < T , P = any > (
41
+ factory : ( props : P ) => T ,
42
+ options ?: Partial < CreateSuperContextOptions < T > >
43
+ ) : [ ( props : P ) => SuperContextDefinition < P , T > , ( ) => T ] ;
36
44
export function createSuperContext < T , P = any > (
37
45
factory : ( props : P ) => T ,
38
46
options : Partial < CreateSuperContextOptions < T > > = { }
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ export type SuperContextProps = PropsWithChildren<{
5
5
/**
6
6
* Contexts provided by the SuperContext.
7
7
*/
8
- contexts : ( SuperContextDefinition | ( ( props ?: any ) => SuperContextDefinition ) ) [ ] ;
8
+ contexts : ( SuperContextDefinition | ( ( ) => SuperContextDefinition ) ) [ ] ;
9
9
/**
10
10
* Options to apply to all contexts provided by the SuperContext. Will be overwritten by any
11
11
* context specific options.
You can’t perform that action at this time.
0 commit comments