Skip to content

Commit cc0aeaf

Browse files
committed
docs(no-use-context): update examples
1 parent f842c7e commit cc0aeaf

File tree

1 file changed

+8
-26
lines changed

1 file changed

+8
-26
lines changed

website/content/docs/rules/no-use-context.md

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -40,39 +40,21 @@ An **unsafe** codemod is available for this rule.
4040
```tsx
4141
import { useContext } from "react";
4242

43-
const MyComponent = () => {
44-
const value = useContext(MyContext);
45-
return <div>{value}</div>;
46-
};
47-
```
48-
49-
```tsx
50-
import React from "react";
51-
52-
const MyComponent = () => {
53-
const value = React.useContext(MyContext);
54-
return <div>{value}</div>;
55-
};
43+
function Button() {
44+
const theme = useContext(ThemeContext);
45+
// ...
46+
}
5647
```
5748

5849
### Passing
5950

6051
```tsx
6152
import { use } from "react";
6253

63-
const MyComponent = () => {
64-
const value = use(MyContext);
65-
return <div>{value}</div>;
66-
};
67-
```
68-
69-
```tsx
70-
import React from "react";
71-
72-
const MyComponent = () => {
73-
const value = React.use(MyContext);
74-
return <div>{value}</div>;
75-
};
54+
function Button() {
55+
const theme = use(ThemeContext);
56+
// ...
57+
}
7658
```
7759

7860
## Implementation

0 commit comments

Comments
 (0)