Skip to content

Commit 1ff8841

Browse files
committed
wip
1 parent 721d93c commit 1ff8841

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/content/blog/2025/04/01/react-labs-what-we-have-been-working-on-april-2025.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ For more info on tickets, free streaming, sponsoring, and more, see [the React C
2626

2727
</Note>
2828

29-
Today, we're excited to release docs for three new experimental features ready for testing:
29+
Today, we're excited to release docs for two new experimental features ready for testing:
3030

3131
- [View Transitions](#view-transitions)
3232
- [Activity](#activity)
@@ -12932,15 +12932,15 @@ useEffect(() => {
1293212932
}, [roomId]);
1293312933
```
1293412934

12935-
Many users would read this code as "on mount, connect to the roomId. whenever `roomId` changes, disconnect to the old room and re-create the connection". However, this is thinking from the component's lifecycle perspective, which means you will need to think of every compoent lifecycle state to write the effect correctly. This can be difficult, so it's understandble that Effects seem harder than class lifecycles when using component perspecitve.
12935+
Many users would read this code as "on mount, connect to the roomId. whenever `roomId` changes, disconnect to the old room and re-create the connection". However, this is thinking from the component's lifecycle perspective, which means you will need to think of every component lifecycle state to write the effect correctly. This can be difficult, so it's understandble that Effects seem harder than class lifecycles when using component perspective.
1293612936

12937-
### Effects on easy mode {/*effects-on-easy-mode*/}
12937+
### Effects without dependencies {/*effects-without-dependencies*/}
1293812938

1293912939
Instaed, it's better to think from the Effect's perspective. The effect doesn't know about about the component lifecycles. It only describes how to start synchronization and how to stop it. When users think of Effects in this way, their Effects tend to be easier to write, and more resilient to being started and stopped as many times as it’s needed.
1294012940

12941-
We spend some time reseaching why Effects are thought of from the component perspective, and we think one of the resons is the depenedency array. Since you have to write it, it's right there and in your face reminding you of what you're "reacting" to and baiting you into thinking of the component props and state changing.
12941+
We spent some time researching why Effects are thought of from the component perspective, and we think one of the resons is the dependency array. Since you have to write it, it's right there and in your face reminding you of what you're "reacting" to and baiting you into the mental model of 'do this when these values change'.
1294212942

12943-
When we released hooks, we thought this might be the case, but knew it would be solved by ahead-of-time compilation of the depependencies. It's taken longer than expected, but with the React Compiler we can start inserting the dependencies for you:
12943+
When we released hooks, we knew we could make them easier to use with ahead-of-time compilation. With the React Compiler, you're now able to avoid writing `useCallback` and `useMemo` yourself in most cases. For Effects, the compiler can insert the dependencies for you:
1294412944

1294512945
```js
1294612946
useEffect(() => {
@@ -12952,9 +12952,9 @@ useEffect(() => {
1295212952
}); // compiler inserted dependencies.
1295312953
```
1295412954

12955-
With this code, the React Compiler can infer the dependecies for you and insert them automatically so you don't need to see or write them. With features like the IDE exension and `useEffectEvent`, we can provide a CodeLens to show you what the Compiler inserted for times you need to debug, or to optimize by removing a dependency.
12955+
With this code, the React Compiler can infer the dependencies for you and insert them automatically so you don't need to see or write them. With features like the IDE exension and `useEffectEvent`, we can provide a CodeLens to show you what the Compiler inserted for times you need to debug, or to optimize by removing a dependency. This helps reinforce the correct mental model for writing Effects, which can run at any time to synchronize your component or hook's state with something else
1295612956

12957-
Our hope is that automatically inserting dependies is not only easier to write, but that it also makes them easier to understand by forcing you to think in terms of what the effect does, and not in component lifecycles.
12957+
Our hope is that automatically inserting dependencies is not only easier to write, but that it also makes them easier to understand by forcing you to think in terms of what the effect does, and not in component lifecycles.
1295812958

1295912959
---
1296012960

@@ -12970,7 +12970,7 @@ Fragment refs are still being researched. We'll share more when we're closer to
1297012970

1297112971
## Gesture Animations {/*gesture-animations*/}
1297212972

12973-
We're also researching ways to enhance View Transitions to support gesture animations such as swiping to open a menu, or scroll through a photo carosel.
12973+
We're also researching ways to enhance View Transitions to support gesture animations such as swiping to open a menu, or scroll through a photo carousel.
1297412974

1297512975
Gestures present new challenges for a few reasons:
1297612976

0 commit comments

Comments
 (0)