Skip to content

Commit 6b0f84a

Browse files
authored
Use modern way to read context
1 parent a1ddcf5 commit 6b0f84a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/content/reference/react/useEffectEvent.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ But in some cases, you may want to read the most recent props or state inside an
7070
To [read the latest props or state](/learn/separating-events-from-effects#reading-latest-props-and-state-with-effect-events) in your Effect, without making those values reactive, include them in an Effect Event.
7171

7272
```js {7-9,12}
73-
import { useEffect, useContext, useEffectEvent } from 'react';
73+
import { useEffect, use, useEffectEvent } from 'react';
7474

7575
function Page({ url }) {
76-
const { items } = useContext(ShoppingCartContext);
76+
const { items } = use(ShoppingCartContext);
7777
const numberOfItems = items.length;
7878

7979
const onNavigate = useEffectEvent((visitedUrl) => {

0 commit comments

Comments
 (0)