File tree 2 files changed +6
-6
lines changed
docs/basic/getting-started 2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -1556,7 +1556,7 @@ interface ContextState {
1556
1556
// set the type of state you want to handle with context e.g.
1557
1557
name: string | null ;
1558
1558
}
1559
- // set an empty object as default state
1559
+ // set an empty object as default state
1560
1560
const Context = createContext ({} as ContextState );
1561
1561
// set up context provider as you normally would in JavaScript [React Context API](https://reactjs.org/docs/context.html#api)
1562
1562
```
@@ -1586,14 +1586,14 @@ Notice the explicit type arguments which we need because we don't have a default
1586
1586
1587
1587
``` ts
1588
1588
const currentUserContext = createContext <string | undefined >(undefined );
1589
- // ^^^^^^^^^^^^^^^^^^
1589
+ // ^^^^^^^^^^^^^^^^^^^^^^^
1590
1590
```
1591
1591
1592
1592
along with the non-null assertion to tell TypeScript that ` currentUser ` is definitely going to be there:
1593
1593
1594
1594
``` ts
1595
1595
return <div >HELLO {currentUser!.toUpperCase()}! < / div > ;
1596
- // ^
1596
+ // ^
1597
1597
```
1598
1598
1599
1599
This is unfortunate because _ we know_ that later in our app, a ` Provider ` is going to fill in the context.
Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ interface ContextState {
55
55
// set the type of state you want to handle with context e.g.
56
56
name: string | null ;
57
57
}
58
- // set an empty object as default state
58
+ // set an empty object as default state
59
59
const Context = createContext ({} as ContextState );
60
60
// set up context provider as you normally would in JavaScript [React Context API](https://reactjs.org/docs/context.html#api)
61
61
```
@@ -85,14 +85,14 @@ Notice the explicit type arguments which we need because we don't have a default
85
85
86
86
``` ts
87
87
const currentUserContext = createContext <string | undefined >(undefined );
88
- // ^^^^^^^^^^^^^^^^^^
88
+ // ^^^^^^^^^^^^^^^^^^^^^^^
89
89
```
90
90
91
91
along with the non-null assertion to tell TypeScript that ` currentUser ` is definitely going to be there:
92
92
93
93
``` ts
94
94
return <div >HELLO {currentUser!.toUpperCase()}! < / div > ;
95
- // ^
95
+ // ^
96
96
```
97
97
98
98
This is unfortunate because _ we know_ that later in our app, a ` Provider ` is going to fill in the context.
You can’t perform that action at this time.
0 commit comments