react changelog


Here's the latest and greatest from our codebase. We've been busy squashing bugs and adding improvements to make everything smoother and more efficient. Check out the highlights below! 🚀


Bugfixes

  • Import correct prod version of jsx-dev-runtime for react-server (#28939)

    • Fixed an issue where the incorrect production version of jsx-dev-runtime was being imported for react-server. Now, the correct version is used based on the environment, ensuring consistency and efficiency in production builds.
  • DevTools: Fix inspecting components with multiple reads of the same Context in React 17 (#28974)

    • Addressed a bug in DevTools where inspecting components with multiple reads of the same Context in React 17 wasn't working properly. Now, the context dependencies are handled correctly, and the values are accurately displayed in DevTools.
  • fix: add react-server condition for react/jsx-dev-runtime (#28921)

    • Added a react-server condition for react/jsx-dev-runtime. This involved updating the package.json and bundles.js scripts to include the necessary files and configurations for the react-server condition.

Improvements

  • Update compiled-rn destination paths to vendor/react (#28989)

    • Updated the destination paths in fbsource from vendor/* to vendor/react/*. This change streamlines the file structure, making it more organized and consistent within the repository. 🎉
  • Use undici polyfill for tests in old Node versions (#28887)

    • Introduced the undici polyfill library for testing FormData/File dependent features in older Node.js versions. This update ensures that our tests are more reliable and compatible with older Node.js versions.
  • Move useMemoCache hook to react/compiler-runtime (#28954)

    • Moved the useMemoCache hook to react/compiler-runtime for Meta-internal purposes. This reorganization helps keep the export on react itself to reduce churn while ensuring proper access to the hook across the codebase.

Stay tuned for more updates, and happy coding! 😎

Included Commits

2024-05-02T20:08:41 See commit

This commit addresses an issue in DevTools related to inspecting components with multiple reads of the same Context in React 17. The changes include modifications to the ReactDebugHooks.js file, where the code now handles the scenario of reading the same context multiple times more effectively. Specifically, it introduces a check for 'memoizedValue' and adjusts the logic accordingly to handle the scenario before React 18 when 'memoizedValue' was not available. This change ensures that the context dependencies are properly advanced and the correct value is returned when reading the context.

Additionally, modifications were made to the ReactHooksInspectionIntegration-test.js file to test the inspection of the current provider value in useContext when reading the same context multiple times. The test case now includes multiple useContext calls for different contexts and verifies the values returned by inspecting the hooks of the component. This enhancement ensures that the DevTools can accurately inspect and display the values of contexts when components make multiple reads of the same context.

Files changed

  • packages/react-debug-tools/src/ReactDebugHooks.js
  • packages/react-debug-tools/src/__tests__/ReactHooksInspectionIntegration-test.js
2024-05-03T20:29:09 See commit

This commit updates the project to use the undici polyfill library for tests in older Node.js versions. The reason for this change is that the current Node.js version used in CI does not support testing FormData/File dependent features. The recommended minimum version for full support is Node.js 18. The undici library is used as a polyfill for FormData/Blob/File features in older Node.js versions, as JSDOM is not a faithful implementation of these APIs. The commit also includes tweaks to the Reply client to handle multi-byte typed arrays correctly.

Specific changes include adding the undici library to the package.json file, modifying the ReactFlightReplyClient.js file to adjust the Blob implementation for multi-byte typed arrays, and updating test files to use the polyfill for FormData/Blob/File features. The commit also includes updates to the yarn.lock file to reflect the addition of the undici package.

Files changed

  • package.json
  • packages/react-client/src/ReactFlightReplyClient.js
  • packages/react-client/src/__tests__/ReactFlight-test.js
  • packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMEdge-test.js
  • packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMReplyEdge-test.js
  • yarn.lock
2024-05-03T22:46:43 See commit

This commit updates the destination paths in fbsource from vendor/* to vendor/react/*. The changes are made in the .github/workflows/commit_artifacts.yml file, with modifications including moving React Native renderer files to the new path and updating the folder structure accordingly. The commit also involves renaming the paths for scheduler, react, react-is, and react-test-renderer within the vendor/react directory.

Overall, this update ensures that the compiled-rn destination paths are organized under the vendor/react directory, streamlining the file structure and making it more consistent within the fbsource repository. The changes made in this commit help improve the organization and accessibility of the React Native files and dependencies within the project.

Files changed

  • .github/workflows/commit_artifacts.yml
2024-04-27T19:45:52 See commit

This commit addresses the need to add a react-server condition for react/jsx-dev-runtime. The changes include adding the jsx-dev-runtime.react-server.js file and modifying the package.json file to include this new file. Additionally, the jsx-dev-runtime.react-server.js file was added to the package.json script section, specifying the path for the react-server condition. The bundles.js script was also modified to include the React JSX DEV Runtime React Server bundle, defining its entry point and conditions.

Overall, this commit ensures that the necessary files and configurations are in place to support the react-server condition for react/jsx-dev-runtime. It adds new files, modifies existing ones, and updates the script to include the React JSX DEV Runtime React Server bundle, making it easier to manage and utilize this feature within the project.

Files changed

  • packages/react/jsx-dev-runtime.react-server.js
  • packages/react/npm/jsx-dev-runtime.react-server.js
  • packages/react/package.json
  • scripts/rollup/bundles.js
2024-04-27T20:25:25 See commit

This commit updates the import statement for the correct production version of jsx-dev-runtime for react-server. The changes include modifying the file jsx-dev-runtime.react-server.js to import the production version without the ".min" suffix. This ensures that the correct production version is used when the NODE_ENV is set to 'production', while the development version is used otherwise.

By making this change, the code now correctly imports the production version of jsx-dev-runtime for react-server, ensuring that the appropriate version is used based on the environment. This helps to maintain consistency and efficiency in the codebase by using the correct version for production builds.

Files changed

  • packages/react/npm/jsx-dev-runtime.react-server.js
2024-04-30T16:00:22 See commit

This commit moves the useMemoCache hook to react/compiler-runtime for Meta-internal purposes. The export is kept on the react itself to reduce churn. The useMemoCache hook is now accessed through 'react/compiler-runtime' in various files, such as ReactHooksInspectionIntegration-test.js, UseMemoCache.js, and useMemoCache-test.js. Additionally, changes were made to package.json, ReactClient.js, ReactFeatureFlags.test-renderer.js, and ReactFeatureFlags.js to reflect this reorganization. The commit also includes modifications to the bundles.js script to handle the Compiler Runtime module separately.

Overall, this commit reorganizes the useMemoCache hook by moving it to react/compiler-runtime for Meta-internal purposes, while still keeping the export on react to minimize disruptions. This change affects multiple files and configurations to ensure proper access to the useMemoCache hook in different parts of the codebase.

Files changed

  • packages/react-debug-tools/src/__tests__/ReactHooksInspectionIntegration-test.js
  • packages/react-devtools-shell/src/app/InspectableElements/UseMemoCache.js
  • packages/react-reconciler/src/__tests__/useMemoCache-test.js
  • packages/react/compiler-runtime.js
  • packages/react/index.classic.fb.js
  • packages/react/index.experimental.js
  • packages/react/index.js
  • packages/react/index.modern.fb.js
  • packages/react/npm/compiler-runtime.js
  • packages/react/package.json
  • packages/react/src/ReactClient.js
  • packages/shared/ReactFeatureFlags.js
  • packages/shared/forks/ReactFeatureFlags.test-renderer.js
  • scripts/rollup/bundles.js