You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/blog/2025/04/01/react-labs-what-we-have-been-working-on-april-2025.md
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,7 @@ For more info on tickets, free streaming, sponsoring, and more, see [the React C
26
26
27
27
</Note>
28
28
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:
30
30
31
31
-[View Transitions](#view-transitions)
32
32
-[Activity](#activity)
@@ -12932,15 +12932,15 @@ useEffect(() => {
12932
12932
}, [roomId]);
12933
12933
```
12934
12934
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.
12936
12936
12937
-
### Effects on easy mode {/*effects-on-easy-mode*/}
12937
+
### Effects without dependencies {/*effects-without-dependencies*/}
12938
12938
12939
12939
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.
12940
12940
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'.
12942
12942
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:
12944
12944
12945
12945
```js
12946
12946
useEffect(() => {
@@ -12952,9 +12952,9 @@ useEffect(() => {
12952
12952
}); // compiler inserted dependencies.
12953
12953
```
12954
12954
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
12956
12956
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.
12958
12958
12959
12959
---
12960
12960
@@ -12970,7 +12970,7 @@ Fragment refs are still being researched. We'll share more when we're closer to
12970
12970
12971
12971
## Gesture Animations {/*gesture-animations*/}
12972
12972
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.
12974
12974
12975
12975
Gestures present new challenges for a few reasons:
0 commit comments