Skip to content

Conversation

@huntie
Copy link
Member

@huntie huntie commented Aug 21, 2025

Summary:
This is a runtime behaviour fix and an API change to Appearance.setColorScheme, motivated by a user report where providing 'unspecified' (valid) to this function would trigger an incorrect invariant throw. Furthermore, there is already a first party use where we call Appearance.setColorScheme('unspecified').

Changes

  • Appearance.d.ts (current public API, manual types): Fix ColorSchemeName type to include 'unspecified' value, and narrow to remove nullability — aligning with existing Flow source for this type in NativeAppearance.
  • Appearance.js (implementation): Fix the invariant throw by removing it, and instead narrowing the input type to non-nullable. Redundant work in getState and getColorScheme is removed.

Changelog: [General][Breaking] Appearance.setColorScheme no longer accepts a nullable value

Differential Revision: D80705652

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 21, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D80705652

@react-native-bot
Copy link
Collaborator

react-native-bot commented Aug 21, 2025


Warnings
⚠️ ❗ JavaScript API change detected - This PR commits an update to ReactNativeApi.d.ts, indicating a change to React Native's public JavaScript API. Please include a clear changelog message. This change will be subject to extra review.

This change was flagged as: BREAKING

Generated by 🚫 dangerJS against f178018

huntie added a commit to huntie/react-native that referenced this pull request Aug 26, 2025
…ebook#53397)

Summary:

This is a runtime behaviour fix and an API change to `Appearance.setColorScheme`, motivated by a user report where providing `'unspecified'` (valid) to this function would trigger an incorrect invariant throw. Furthermore, there is already a [first party use](https://github.com/facebook/react-native/blob/aec35b896053d9372ccdaf67c939b2eb216d3455/packages/react-native/Libraries/Utilities/Appearance.js#L101) where we call `Appearance.setColorScheme('unspecified')`.

**Changes**

- `Appearance.d.ts` (current public API, manual types): Fix `ColorSchemeName` type to include `'unspecified'` value, and narrow to remove nullability — aligning with existing Flow source for this type in `NativeAppearance`.
- `Appearance.js` (implementation): Fix the invariant throw by **removing it**, and instead narrowing the input type to non-nullable. Redundant work in `getState` and `getColorScheme` is removed.

Changelog: [General][Breaking] `Appearance.setColorScheme` no longer accepts a nullable value

Differential Revision: D80705652
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D80705652

huntie added a commit to huntie/react-native that referenced this pull request Aug 29, 2025
…ebook#53397)

Summary:

This is a runtime behaviour fix and an API change to `Appearance.setColorScheme`, motivated by a user report where providing `'unspecified'` (valid) to this function would trigger an incorrect invariant throw. Furthermore, there is already a [first party use](https://github.com/facebook/react-native/blob/aec35b896053d9372ccdaf67c939b2eb216d3455/packages/react-native/Libraries/Utilities/Appearance.js#L101) where we call `Appearance.setColorScheme('unspecified')`.

**Changes**

- `Appearance.d.ts` (current public API, manual types): Fix `ColorSchemeName` type to include `'unspecified'` value, and narrow to remove nullability — aligning with existing Flow source for this type in `NativeAppearance`.
- `Appearance.js` (implementation): Fix the invariant throw by **removing it**, and instead narrowing the input type to non-nullable. Redundant work in `getState` and `getColorScheme` is removed.

Changelog: [General][Breaking] `Appearance.setColorScheme` no longer accepts a nullable value

Reviewed By: andrewdacenko

Differential Revision: D80705652
…ebook#53397)

Summary:
Pull Request resolved: facebook#53397

This is a runtime behaviour fix and an API change to `Appearance.setColorScheme`, motivated by a user report where providing `'unspecified'` (valid) to this function would trigger an incorrect invariant throw. Furthermore, there is already a [first party use](https://github.com/facebook/react-native/blob/aec35b896053d9372ccdaf67c939b2eb216d3455/packages/react-native/Libraries/Utilities/Appearance.js#L101) where we call `Appearance.setColorScheme('unspecified')`.

**Changes**

- `Appearance.d.ts` (current public API, manual types): Fix `ColorSchemeName` type to include `'unspecified'` value, and narrow to remove nullability — aligning with existing Flow source for this type in `NativeAppearance`.
- `Appearance.js` (implementation): Fix the invariant throw by **removing it**, and instead narrowing the input type to non-nullable. Redundant work in `getState` and `getColorScheme` is removed.

Changelog: [General][Breaking] `Appearance.setColorScheme` no longer accepts a nullable value

Reviewed By: andrewdacenko

Differential Revision: D80705652
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D80705652

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Aug 29, 2025
@facebook-github-bot
Copy link
Contributor

This pull request has been merged in a4581ec.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @huntie in a4581ec

When will my fix make it into a release? | How to file a pick request?

@huntie huntie deleted the export-D80705652 branch August 30, 2025 08:58
@huntie huntie added the JS API refinements (2025) Follow-up items from our JS API changes in 0.80 (deep imports deprecation and Strict TypeScript API) label Aug 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported JS API refinements (2025) Follow-up items from our JS API changes in 0.80 (deep imports deprecation and Strict TypeScript API) Merged This PR has been merged. p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants