Skip to content

Commit 417d163

Browse files
author
swyx
committed
format'
gpom
1 parent 39736ac commit 417d163

File tree

3 files changed

+20
-25
lines changed

3 files changed

+20
-25
lines changed

docs/basic/getting-started/context.md

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,50 +5,45 @@ title: Context
55

66
## Basic Example
77

8-
98
```tsx
10-
import * as React from 'react';
9+
import * as React from "react";
1110

1211
interface AppContextInterface {
13-
name: string,
14-
author: string,
15-
url: string
12+
name: string;
13+
author: string;
14+
url: string;
1615
}
1716

1817
const AppCtx = React.createContext<AppContextInterface | null>(null);
1918

2019
// Provider in your app
2120

2221
const sampleAppContext: AppContextInterface = {
23-
name: 'Using React Context in a Typescript App',
24-
author: 'thehappybug',
25-
url: 'http://www.example.com'
22+
name: "Using React Context in a Typescript App",
23+
author: "thehappybug",
24+
url: "http://www.example.com",
2625
};
2726

2827
export const App = () => (
29-
<AppCtx.Provider value={sampleAppContext}>
30-
...
31-
</AppCtx.Provider>
28+
<AppCtx.Provider value={sampleAppContext}>...</AppCtx.Provider>
3229
);
3330

3431
// Consume in your app
3532

3633
export const PostInfo = () => {
37-
const appContext = React.useContext(AppCtx)
34+
const appContext = React.useContext(AppCtx);
3835
return (
39-
<div>
40-
Name: {appContext.name},
41-
Author: {appContext.author},
42-
Url: {appContext.url}
43-
</div>
44-
)
45-
}
36+
<div>
37+
Name: {appContext.name}, Author: {appContext.author}, Url:{" "}
38+
{appContext.url}
39+
</div>
40+
);
41+
};
4642
```
4743

4844
You can also use the [Class.contextType](https://reactjs.org/docs/context.html#classcontexttype) or [Context.Consumer](https://reactjs.org/docs/context.html#contextconsumer) API, let us know if you have trouble with that.
4945

50-
51-
*[Thanks to @AlvSovereign](https://github.com/typescript-cheatsheets/react/issues/97)*
46+
_[Thanks to @AlvSovereign](https://github.com/typescript-cheatsheets/react/issues/97)_
5247

5348
## Extended Example
5449

docs/basic/troubleshooting/types.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ let baz2: SubIsntType2 = {
370370
371371
## The Types I need don't exist!
372372
373-
What's more annoying than modules with unexported types? Modules that are **untyped**!
373+
What's more annoying than modules with unexported types? Modules that are **untyped**!
374374
375375
> Before you proceed - make sure you have checked that types don't exist in [DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped) or [TypeSearch](https://microsoft.github.io/TypeSearch/)
376376
@@ -404,9 +404,9 @@ This solution works well as a workaround if you have less than a couple untyped
404404
405405
### Autogenerate types
406406
407-
You can use TypeScript with `--allowJs` and `--declaration` to see TypeScript's "best guess" at the types of the library.
407+
You can use TypeScript with `--allowJs` and `--declaration` to see TypeScript's "best guess" at the types of the library.
408408
409-
If this doesn't work well enough, use [`dts-gen`](https://github.com/Microsoft/dts-gen) to use the runtime shape of the object to accurately enumerate all available properties. This tends to be very accurate, BUT the tool does not yet support scraping JSDoc comments to populate additional types.
409+
If this doesn't work well enough, use [`dts-gen`](https://github.com/Microsoft/dts-gen) to use the runtime shape of the object to accurately enumerate all available properties. This tends to be very accurate, BUT the tool does not yet support scraping JSDoc comments to populate additional types.
410410
411411
```bash
412412
npm install -g dts-gen

docs/migration/from-js.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ title: From JS
88
- [TypeStat](https://github.com/JoshuaKGoldberg/TypeStat) ([used by Codecademy](https://mobile.twitter.com/JoshuaKGoldberg/status/1159090281314160640))
99
- [TypeWiz](https://github.com/urish/typewiz)
1010
- [js-to-ts-converter](https://github.com/gregjacobs/js-to-ts-converter)
11-
- [TS-migrate](https://medium.com/airbnb-engineering/ts-migrate-a-tool-for-migrating-to-typescript-at-scale-cd23bfeb5cc) from Airbnb
11+
- [TS-migrate](https://medium.com/airbnb-engineering/ts-migrate-a-tool-for-migrating-to-typescript-at-scale-cd23bfeb5cc) from Airbnb
1212
- [dts-gen](https://github.com/microsoft/dts-gen) - `dts-gen` is a tool that generates TypeScript definition files (.d.ts) from any JavaScript object.
1313

1414
## Manual JS to TS Conversion

0 commit comments

Comments
 (0)