Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FeatureFlags] Enable useMemoCache for ReactTestRenderer #27677

Merged
merged 1 commit into from
Nov 10, 2023

Conversation

mofeiZ
Copy link
Contributor

@mofeiZ mofeiZ commented Nov 9, 2023

Summary

Forget compiled code currently cannot be tested with ReactTestRender as useMemoCache is not being set on the dispatcher. This PR ensures that projects can execute unit tests with Forget compilation in the test build pipeline.

// source code
function Component(props) {
  // ...
}

// transformed code, which also should be evaluated in unit tests
function Component(props) {
  const $ = useMemoCache(...);
  // ...
}

This PR enables the enableUseMemoCacheHook feature flag for all bundle variations of ReactTestRenderer. Forget should be the only caller of useMemoCache, so this should be a reversible change (in the event we need to change the implementation or api of the hook).

How did you test this change?

  • Check that generated ReactTestRenderer bundles contain useMemoCache.
  • Synced to Meta and checked that unit tests that use Forget + @testing-library/react pass.

I did not add new tests to check that useMemoCache can be called when using the test renderer as useMemoCache is not yet stable. Happy to add a test case here if that would be helpful to reviewers though (I'm guessing that would go in packages/react-test-renderer/src/__tests__/ReactTestRenderer-test.js )

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Nov 9, 2023
@react-sizebot
Copy link

Comparing: 7468903...b712190

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.min.js = 175.90 kB 175.90 kB = 54.76 kB 54.75 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 177.97 kB 177.97 kB = 55.40 kB 55.39 kB
facebook-www/ReactDOM-prod.classic.js = 569.66 kB 569.66 kB = 100.26 kB 100.26 kB
facebook-www/ReactDOM-prod.modern.js = 553.51 kB 553.51 kB = 97.35 kB 97.35 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
facebook-react-native/react-test-renderer/cjs/ReactTestRenderer-prod.js +0.47% 311.07 kB 312.52 kB +0.59% 54.95 kB 55.28 kB
facebook-react-native/react-test-renderer/cjs/ReactTestRenderer-profiling.js +0.44% 326.96 kB 328.41 kB +0.54% 57.40 kB 57.71 kB
facebook-react-native/react-test-renderer/cjs/ReactTestRenderer-dev.js +0.33% 926.97 kB 930.06 kB +0.29% 185.50 kB 186.03 kB
facebook-www/ReactTestRenderer-dev.modern.js +0.33% 939.20 kB 942.28 kB +0.28% 187.46 kB 187.99 kB
facebook-www/ReactTestRenderer-dev.classic.js +0.33% 939.20 kB 942.29 kB +0.28% 187.46 kB 187.99 kB

Generated by 🚫 dangerJS against b712190

@mofeiZ mofeiZ marked this pull request as ready for review November 9, 2023 22:16
@mofeiZ mofeiZ merged commit 6a7f3aa into facebook:main Nov 10, 2023
github-actions bot pushed a commit that referenced this pull request Nov 10, 2023
## Summary
Forget compiled code currently cannot be tested with ReactTestRender as
`useMemoCache` is not being set on the dispatcher. This PR ensures that
projects can execute unit tests with Forget compilation in the test
build pipeline.

```js
// source code
function Component(props) {
  // ...
}

// transformed code, which also should be evaluated in unit tests
function Component(props) {
  const $ = useMemoCache(...);
  // ...
}
```

This PR enables the `enableUseMemoCacheHook` feature flag for all bundle
variations of ReactTestRenderer. Forget *should* be the only caller of
useMemoCache, so this should be a reversible change (in the event we
need to change the implementation or api of the hook).

## How did you test this change?
* Check that generated ReactTestRenderer bundles contain `useMemoCache`.
* Synced to Meta and checked that unit tests that use Forget +
@testing-library/react pass.

I did not add new tests to check that useMemoCache can be called when
using the test renderer as `useMemoCache` is not yet stable. Happy to
add a test case here if that would be helpful to reviewers though (I'm
guessing that would go in
`packages/react-test-renderer/src/__tests__/ReactTestRenderer-test.js` )

DiffTrain build for [6a7f3aa](6a7f3aa)
kodiakhq bot pushed a commit to vercel/next.js that referenced this pull request Nov 15, 2023
EdisonVan pushed a commit to EdisonVan/react that referenced this pull request Apr 15, 2024
)

## Summary
Forget compiled code currently cannot be tested with ReactTestRender as
`useMemoCache` is not being set on the dispatcher. This PR ensures that
projects can execute unit tests with Forget compilation in the test
build pipeline.

```js
// source code
function Component(props) {
  // ...
}

// transformed code, which also should be evaluated in unit tests
function Component(props) {
  const $ = useMemoCache(...);
  // ...
}
```

This PR enables the `enableUseMemoCacheHook` feature flag for all bundle
variations of ReactTestRenderer. Forget *should* be the only caller of
useMemoCache, so this should be a reversible change (in the event we
need to change the implementation or api of the hook).

## How did you test this change?
* Check that generated ReactTestRenderer bundles contain `useMemoCache`.
* Synced to Meta and checked that unit tests that use Forget +
@testing-library/react pass.

I did not add new tests to check that useMemoCache can be called when
using the test renderer as `useMemoCache` is not yet stable. Happy to
add a test case here if that would be helpful to reviewers though (I'm
guessing that would go in
`packages/react-test-renderer/src/__tests__/ReactTestRenderer-test.js` )
bigfootjon pushed a commit that referenced this pull request Apr 18, 2024
## Summary
Forget compiled code currently cannot be tested with ReactTestRender as
`useMemoCache` is not being set on the dispatcher. This PR ensures that
projects can execute unit tests with Forget compilation in the test
build pipeline.

```js
// source code
function Component(props) {
  // ...
}

// transformed code, which also should be evaluated in unit tests
function Component(props) {
  const $ = useMemoCache(...);
  // ...
}
```

This PR enables the `enableUseMemoCacheHook` feature flag for all bundle
variations of ReactTestRenderer. Forget *should* be the only caller of
useMemoCache, so this should be a reversible change (in the event we
need to change the implementation or api of the hook).

## How did you test this change?
* Check that generated ReactTestRenderer bundles contain `useMemoCache`.
* Synced to Meta and checked that unit tests that use Forget +
@testing-library/react pass.

I did not add new tests to check that useMemoCache can be called when
using the test renderer as `useMemoCache` is not yet stable. Happy to
add a test case here if that would be helpful to reviewers though (I'm
guessing that would go in
`packages/react-test-renderer/src/__tests__/ReactTestRenderer-test.js` )

DiffTrain build for commit 6a7f3aa.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants