We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
react changelog
Here's a detailed breakdown of the recent changes and improvements. We've been busy making things smoother, faster, and more awesome! 🚀
New Features
-
Async Dispatcher for Current Owner and Cache: We've moved the current owner and cache to an Async Dispatcher in React. This significant change ensures better handling and synchronization, reducing the risk of lost updates. Various files were updated to implement this, including ReactSharedInternals and ReactFiberCurrentOwner.
-
Support for (Async) Generator Server Components: React now supports rendering (Async) Generator Server Components. This allows the use of generator functions in Server Components, making it easier and more efficient to handle async operations.
-
React 19 Issue Template: A new issue template for React 19 beta has been added. This template will streamline the process of reporting issues, ensuring that all necessary information is provided for quick resolution.
-
Changelog for Version 18.3.1: Added a detailed changelog for version 18.3.1, highlighting specific changes like the export of
act
fromreact
.
Improvements
-
Ref Cleanup Function for Imperative Handle Refs: Introduced support for a ref cleanup function for imperative handle refs. This enhancement allows developers to define cleanup functions for these refs, ensuring proper handling during updates and unmounting.
-
Update Canary Channel Label to "Beta": During the beta period, canaries will be published and tagged as
beta
when released to npm. This ensures clear versioning and labeling during the beta phase.
Bugfixes
-
Remove Automatic Fetch
Cache
Instrumentation: Removed the automatic patching of the globalfetch
function in Server Components environments. This decision was made to avoid controversy and objections from some RSC framework maintainers. -
Remove Warning for Ref Cleanup Function: Cleaned up the warning related to the cleanup function for refs in React. This warning has been active since version 18.0.0 and is now removed for version 19.
-
Unrevert "Support Writing to this.refs from Userspace": Reverted a previous change to support writing to
this.refs
from userspace again. The regression cause was identified and addressed, allowing this feature to be re-implemented.
Chore
- Cleanup of
replayFailedUnitOfWorkWithInvokeGuardedCallback
andenableProfilerNestedUpdateScheduledHook
: Streamlined the code by removing unnecessary flags, ensuring the codebase is clean and focused on essential features.
We hope you enjoy these updates and improvements! Keep coding and stay awesome! 😎✨
Included Commits
This commit adds support for rendering (Async) Generator Server Components in React. It explains that React supports rendering Iterable
and will soon support AsyncIterable
, but Iterator
and AsyncIterator
types are not directly supported as children of React due to the need to rerender with new inputs during an update. However, a special case is made for generator functions, where the React Element itself can act as an Iterable
because a new generator can be created whenever needed. This proposal aims to special case the Generator
/AsyncGenerator
returned by a (Async) Generator Function in Server Components.
The changes in the commit involve modifications to ReactFlight-test.js and ReactFlightServer.js, adding support for rendering a Generator Server Component as a fragment and handling the serialization of Iterator/AsyncIterator as multi-shot to be compatible with React Children. It also includes updates to handle special cases in SuspenseList
for components that generate rows, allowing for the use of AsyncGeneratorFunction
in such scenarios.
Files changed
- packages/react-client/src/__tests__/ReactFlight-test.js
- packages/react-server/src/ReactFlightServer.js
This commit removes a warning related to the cleanup function for refs in React. The warning was implemented in a previous version and has been active since version 18.0.0. The warning was triggered even though the new feature had been enabled in the canary build for some time. This PR cleans up the warning for version 19, removing unnecessary warnings related to the cleanup function for refs.
The changes include modifications in the refs-test.js file and ReactFiberCommitWork.js file. The cleanup function for refs was causing a warning to be triggered, and this commit removes that warning. The commit also includes changes to safely detach the ref in certain cases. Overall, this commit aims to improve the user experience by removing unnecessary warnings related to the cleanup function for refs in React.
Files changed
- packages/react-dom/src/__tests__/refs-test.js
- packages/react-reconciler/src/ReactFiberCommitWork.js
This commit involves cleaning up the replayFailedUnitOfWorkWithInvokeGuardedCallback
and enableProfilerNestedUpdateScheduledHook
functions in the React codebase. The changes made include removing the enableProfilerNestedUpdateScheduledHook
and replayFailedUnitOfWorkWithInvokeGuardedCallback
flags from the loadModules
function in the ReactProfilerComponent-test.internal.js file. These flags were previously set to false, but they have been removed as part of the cleanup process.
Overall, this commit streamlines the code by eliminating unnecessary flags and ensuring that only essential features are included in the loadModules
function. By removing these flags, the codebase becomes cleaner and more focused on the core functionalities of the React library.
Files changed
- packages/react/src/__tests__/ReactProfilerComponent-test.internal.js
This commit removes the automatic patching of the global fetch
function in Server Components environments to dedupe requests using React.cache
. This decision was made due to objections from some RSC framework maintainers, and the controversy surrounding this behavior. The implementation has been removed, and frameworks that have already implemented this behavior, like Next.js, can choose to reimplement it in userspace if desired. The commit also mentions the possibility of revisiting this decision in the future, but for now, it has been deemed not worth the controversy.
To address the issue of disabling the implementation by setting enableFetchInstrumentation
to false
everywhere, it was decided that this approach would also disable the tests, leading to potential behavior drift without test coverage. Therefore, the decision was made to remove the implementation entirely instead of just disabling it. If needed, the changes can be reverted later on. The commit includes changes in various files related to feature flags and the ReactServer
module to reflect the removal of the automatic fetch cache
instrumentation.
Files changed
- packages/react/src/ReactServer.experimental.js
- packages/react/src/ReactServer.js
- packages/shared/ReactFeatureFlags.js
- packages/shared/forks/ReactFeatureFlags.native-fb.js
- packages/shared/forks/ReactFeatureFlags.native-oss.js
- packages/shared/forks/ReactFeatureFlags.test-renderer.js
- packages/shared/forks/ReactFeatureFlags.test-renderer.native-fb.js
- packages/shared/forks/ReactFeatureFlags.test-renderer.www.js
- packages/shared/forks/ReactFeatureFlags.www.js
This commit reverts a previous change made in commit #28877 in the Facebook React repository. The reason for the reversion is that the team found the cause of the regression and believes they can successfully implement the change again. The specific changes made in this commit involve modifications to the ReactFiberClassComponent.js file, with additions, deletions, and changes totaling 12. The main change involves enabling the ability to write to this.refs from userspace, with additional adjustments related to debugging, context, and scheduling features.
One significant change made in this commit is the modification of the mountClassInstance function to allow for writable string refs in create-react-class legacy components. By setting instance.refs to an empty object under certain conditions, the team aims to address issues related to string refs in these components. Overall, the commit aims to address the regression caused by the previous change and make the necessary adjustments to support writing to this.refs from userspace effectively.
Files changed
- packages/react-reconciler/src/ReactFiberClassComponent.js
This commit introduces support for a ref cleanup function for imperative handle refs in React. The changes include modifications to the refs-test.js file in the react-dom package. The commit adds tests for using imperative handle refs with object and callback style refs, including testing cleanup functions when updating dependencies and unmounting components. Additionally, the ReactFiberHooks.js file in the react-reconciler package was modified to handle the ref cleanup logic.
Overall, this update enhances the functionality of imperative handle refs in React by allowing developers to define cleanup functions for these refs. The tests added in the commit ensure that the cleanup functions work correctly when updating, unmounting, or recreating components with imperative handle refs using both object and callback styles. The changes in the ReactFiberHooks file ensure that the ref cleanup logic is properly handled for different types of ref callbacks.
Files changed
- packages/react-dom/src/__tests__/refs-test.js
- packages/react-reconciler/src/ReactFiberHooks.js
This commit updates the canary channel label to "beta" during the beta period. Canaries will now be published as 19.0.0-beta-<COMMIT_SHA>-<DATE>
and tagged as beta
when published to npm. The changes include modifying the .circleci/config.yml
file to update the dist_tag from "canary,next" to "canary,next,beta" in the workflows section. Additionally, the ReactVersions.js
file has been modified to change the canary channel label from 'canary' to 'beta' in the ReactVersion constant.
Overall, this commit ensures that during the beta period, canaries are labeled and tagged appropriately as beta versions. The necessary changes have been made in the configuration file and ReactVersions file to reflect this update.
Files changed
- .circleci/config.yml
- ReactVersions.js
This commit moves the current owner and cache to an Async Dispatcher in React. The PR was rebased and landed to avoid the possibility of lost updates. Changes were made in various files to implement this, such as updating the import of ReactSharedInternals, modifying the ReactCompositeComponent-test file, and adding a new ReactFiberCurrentOwner file to handle the current owner. Additionally, changes were made in ReactNativePublicCompat, ReactFiberAsyncDispatcher, ReactFiberBeginWork, and other related files to accommodate this transition. The commit also includes modifications in ReactSharedInternalsClient and ReactSharedInternalsServer to reflect these changes. Overall, the current owner and cache are now handled through the Async Dispatcher in React.
Files changed
- packages/react-dom/src/__tests__/ReactCompositeComponent-test.js
- packages/react-dom/src/client/ReactDOMRootFB.js
- packages/react-native-renderer/src/ReactNativePublicCompat.js
- packages/react-reconciler/src/ReactFiberAsyncDispatcher.js
- packages/react-reconciler/src/ReactFiberBeginWork.js
- packages/react-reconciler/src/ReactFiberCurrentOwner.js
- packages/react-reconciler/src/ReactFiberTreeReflection.js
- packages/react-reconciler/src/ReactFiberWorkLoop.js
- packages/react-reconciler/src/ReactInternalTypes.js
- packages/react-server/src/ReactFizzAsyncDispatcher.js
- packages/react-server/src/ReactFizzServer.js
- packages/react-server/src/ReactFlightServer.js
- packages/react-server/src/flight/ReactFlightAsyncDispatcher.js
- packages/react-suspense-test-utils/src/ReactSuspenseTestUtils.js
- packages/react/src/ReactCacheImpl.js
- packages/react/src/ReactHooks.js
- packages/react/src/ReactSharedInternalsClient.js
- packages/react/src/ReactSharedInternalsServer.js
- packages/react/src/jsx/ReactJSXElement.js
This commit adds a new issue template for reporting issues with React 19 beta. The template includes sections for providing a summary of the issue, as well as instructions for providing a CodeSandbox, GitHub repository link, or minimal code example to reproduce the problem. It also includes a section for attaching relevant screenshots of the application. This template aims to streamline the process of reporting and resolving issues related to React 19 beta by providing clear guidelines for users to follow.
Overall, this commit introduces a structured template that will help streamline the issue reporting process for React 19 beta. By providing clear instructions and sections for key information, it will make it easier for users to report issues effectively, ultimately leading to faster resolution and improvement of the beta version.
Files changed
- .github/ISSUE_TEMPLATE/19.md
In this commit, a changelog for version 18.3.1 was added. The changelog includes information about the changes made in this version, with 4 additions and no deletions. Specifically, it mentions the export of act
from react
with a link to the specific commit that made this change. This version is noted to be released on April 26, 2024, following version 18.3.0 which was released the day before and included warnings for deprecated APIs and other changes necessary for React 19.
Overall, this commit adds a detailed entry for version 18.3.1 to the changelog, highlighting the specific changes made in this release. It provides a clear overview of the modifications, including the addition of the export act
from react
, and serves as a useful reference for developers to track the updates and improvements in this version of the software.
Files changed
- CHANGELOG.md