Skip to content

Conversation

@josephsavona
Copy link
Member

@josephsavona josephsavona commented Oct 16, 2025

This is a great validation, so let's enable by default. Changes:

  • Move the validation logic into ValidateUseMemo alongside the new check that the useMemo result is used
  • Update the lint description
  • Make the void memo errors lint-only, they don't require us to skip compilation (as evidenced by the fact that we've had this validation off)

Stack created with Sapling. Best reviewed with ReviewStack.

josephsavona added a commit that referenced this pull request Oct 16, 2025
Two additional validations for useMemo:
* Disallow reassigning to values declared outside the useMemo callback
(always on)
* Disallow unused useMemo calls (part of the validateNoVoidUseMemo
feature flag, which in turn is off by default)

We should probably enable this flag though!

---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/facebook/react/pull/34868).
* #34855
* #34882
* __->__ #34868
This is a great validation, so let's enable by default. Changes:
* Move the validation logic into ValidateUseMemo alongside the new check that the useMemo result is used
* Update the lint description
* Make the void memo errors lint-only, they don't require us to skip compilation (as evidenced by the fact that we've had this validation off)
@josephsavona josephsavona merged commit 1324e1b into main Oct 16, 2025
11 of 12 checks passed
github-actions bot pushed a commit that referenced this pull request Oct 16, 2025
Two additional validations for useMemo:
* Disallow reassigning to values declared outside the useMemo callback
(always on)
* Disallow unused useMemo calls (part of the validateNoVoidUseMemo
feature flag, which in turn is off by default)

We should probably enable this flag though!

---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/facebook/react/pull/34868).
* #34855
* #34882
* __->__ #34868

DiffTrain build for [7f5ea1b](7f5ea1b)
github-actions bot pushed a commit that referenced this pull request Oct 16, 2025
Two additional validations for useMemo:
* Disallow reassigning to values declared outside the useMemo callback
(always on)
* Disallow unused useMemo calls (part of the validateNoVoidUseMemo
feature flag, which in turn is off by default)

We should probably enable this flag though!

---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/facebook/react/pull/34868).
* #34855
* #34882
* __->__ #34868

DiffTrain build for [7f5ea1b](7f5ea1b)
github-actions bot pushed a commit that referenced this pull request Oct 16, 2025
This is a great validation, so let's enable by default. Changes:
* Move the validation logic into ValidateUseMemo alongside the new check
that the useMemo result is used
* Update the lint description
* Make the void memo errors lint-only, they don't require us to skip
compilation (as evidenced by the fact that we've had this validation
off)

---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/facebook/react/pull/34882).
* #34855
* __->__ #34882

DiffTrain build for [1324e1b](1324e1b)
github-actions bot pushed a commit that referenced this pull request Oct 16, 2025
This is a great validation, so let's enable by default. Changes:
* Move the validation logic into ValidateUseMemo alongside the new check
that the useMemo result is used
* Update the lint description
* Make the void memo errors lint-only, they don't require us to skip
compilation (as evidenced by the fact that we've had this validation
off)

---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/facebook/react/pull/34882).
* #34855
* __->__ #34882

DiffTrain build for [1324e1b](1324e1b)
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.

3 participants