Skip to content

structuredClone coerces boxed primitives and flips false Boolean #58226

Description

@OskarEichler

Description

The React Native structuredClone polyfill reconstructs Number, String, Boolean, and Date wrappers by passing the source object to a constructor. Number/String cloning invokes user coercion hooks, and new Boolean(new Boolean(false)) uses object truthiness and silently changes the internal value to true.

Expected behavior

Cloning should read each wrapper's internal primitive through the built-in valueOf intrinsic, create a distinct wrapper with the same value, and never execute user coercion. Native structuredClone follows this behavior.

React Native Version

0.87.1 and current main

Affected Platforms

JavaScript runtime - All

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: Author FeedbackNeeds: ReproThis issue could be improved with a clear list of steps to reproduce the issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions