Skip to content

Commit 7d60b63

Browse files
afgoulartAndré Filipe Goulart
authored andcommitted
docs: add note about use preference over useContext (#7723)
1 parent f9e2c13 commit 7d60b63

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/content/reference/react/useContext.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ const value = useContext(SomeContext)
1616

1717
---
1818

19+
<Note>
20+
21+
[`use`](/reference/react/use) is preferred over `useContext` because it is more flexible. Unlike `useContext`, `use` can be called inside conditionals and loops.
22+
23+
</Note>
24+
25+
---
26+
1927
## Reference {/*reference*/}
2028

2129
### `useContext(SomeContext)` {/*usecontext*/}

0 commit comments

Comments
 (0)