Skip to content

Commit fb86c79

Browse files
authored
Update context.md (#592)
* Update context.md Update comments in code blocks * Update README.md
1 parent 3c99a6c commit fb86c79

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,7 +1556,7 @@ interface ContextState {
15561556
// set the type of state you want to handle with context e.g.
15571557
name: string | null;
15581558
}
1559-
//set an empty object as default state
1559+
// set an empty object as default state
15601560
const Context = createContext({} as ContextState);
15611561
// set up context provider as you normally would in JavaScript [React Context API](https://reactjs.org/docs/context.html#api)
15621562
```
@@ -1586,14 +1586,14 @@ Notice the explicit type arguments which we need because we don't have a default
15861586

15871587
```ts
15881588
const currentUserContext = createContext<string | undefined>(undefined);
1589-
// ^^^^^^^^^^^^^^^^^^
1589+
// ^^^^^^^^^^^^^^^^^^^^^^^
15901590
```
15911591

15921592
along with the non-null assertion to tell TypeScript that `currentUser` is definitely going to be there:
15931593

15941594
```ts
15951595
return <div>HELLO {currentUser!.toUpperCase()}!</div>;
1596-
// ^
1596+
// ^
15971597
```
15981598

15991599
This is unfortunate because _we know_ that later in our app, a `Provider` is going to fill in the context.

docs/basic/getting-started/context.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ interface ContextState {
5555
// set the type of state you want to handle with context e.g.
5656
name: string | null;
5757
}
58-
//set an empty object as default state
58+
// set an empty object as default state
5959
const Context = createContext({} as ContextState);
6060
// set up context provider as you normally would in JavaScript [React Context API](https://reactjs.org/docs/context.html#api)
6161
```
@@ -85,14 +85,14 @@ Notice the explicit type arguments which we need because we don't have a default
8585

8686
```ts
8787
const currentUserContext = createContext<string | undefined>(undefined);
88-
// ^^^^^^^^^^^^^^^^^^
88+
// ^^^^^^^^^^^^^^^^^^^^^^^
8989
```
9090

9191
along with the non-null assertion to tell TypeScript that `currentUser` is definitely going to be there:
9292

9393
```ts
9494
return <div>HELLO {currentUser!.toUpperCase()}!</div>;
95-
// ^
95+
// ^
9696
```
9797

9898
This is unfortunate because _we know_ that later in our app, a `Provider` is going to fill in the context.

0 commit comments

Comments
 (0)