Skip to content

Request for Object Serialization Support in cache() Function #29029

Closed as not planned
@ryo-manba

Description

@ryo-manba

Is there any plan to support object serialization in cache() function similar to how modern data fetching libraries handle caching?

Current Behavior

Currently, React's caching mechanism supports only primitive values. This limitation becomes inconvenient when handling multiple properties, necessitating a workaround to manually serialize objects.

React Cache uses a WeakMap to compare object references, requiring the same object reference to utilize caching effectively.

In previous cache implementations, it was possible to pass a function that serializes keys into strings. Is there any plan to readopt this approach?

Examples from Other Libraries

Looking forward to your thoughts!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution: StaleAutomatically closed due to inactivity

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions