Skip to content

Conversation

@maman
Copy link
Contributor

@maman maman commented Dec 9, 2025

Summary:

isPlainObject function defined in AnimatedObject.js doesn't handle Object.create(null) correctly.

this will throws when encountering objects with null prototype:

Object.getPrototypeOf(Object.create(null)).isPrototypeOf(Object)
// TypeError: Cannot read properties of null (reading 'isPrototypeOf')

This breaks compatibility with libraries that use Object.create(null) for creating clean dictionary objects.

Changelog:

[GENERAL] [FIXED] - Handle Object.create(null) correctly in AnimatedObject.js' isPlainObject function

Test Plan:

import { isPlainObject } from 'react-native/Libraries/Animated/nodes/AnimatedObject';

// Before: throws TypeError
// After: returns true
isPlainObject(Object.create(null));

// Existing behavior unchanged
isPlainObject({});           // true
isPlainObject([]);           // false
isPlainObject(null);         // false
isPlainObject(new Date());   // false

@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 Dec 9, 2025
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Dec 9, 2025
Comment on lines 30 to 31
value !== null &&
typeof value === 'object' &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value !== null and typeof checks are duplicated here. Can we simplify this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done. simplified the checks, and adds early return for non-object scenario

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got this comment: #54820 (comment), but I didn't change the return type / any of RN public js api 🤔

manually running the diff-api-snapshot script returns NON_BREAKING rather than BREAKING:

codespace:/workspaces/react-native> git show 9fb2eb517ae017629a1e43bad729068df87780ac:packages/react-native/ReactNativeApi.d.ts
 > ReactNativeApi-after.d.ts
codespace:/workspaces/react-native> node ./scripts/js-api/diff-api-snapshot packages/react-native/ReactNativeApi.d.ts ReactNati
veApi-after.d.ts
{
  "result": "NON_BREAKING",
  "changedApis": []
}

is there anything missing from my side?

@react-native-bot
Copy link
Collaborator


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 9fb2eb5

@meta-codesync
Copy link

meta-codesync bot commented Dec 9, 2025

@zeyap has imported this pull request. If you are a Meta employee, you can view this in D88754908.

@meta-codesync meta-codesync bot closed this in 4e0b923 Dec 17, 2025
@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Dec 17, 2025
@meta-codesync
Copy link

meta-codesync bot commented Dec 17, 2025

@javache merged this pull request in 4e0b923.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @maman in 4e0b923

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

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. Merged This PR has been merged. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants