Skip to content

Support React Native #160

@bsluther

Description

@bsluther

When I tried using @tanstack/db in a React Native (Expo) project, I discovered one issue and one potential issue.

  1. @tanstack/store says in the docs (https://tanstack.com/store/latest/docs/installation) it doesn't support React Native. I thought I saw this mentioned in the Discord but didn't have time to follow-up and couldn't find that thread.
  • I haven't actually "run into" this problem yet, so can't confirm or deny.
  • @KyleAMathews mentioned on Discord that @tanstack/db will no longer use @tanstack/store fairly soon, so this might be a non-issue in a coming release.
  1. The d2ts package makes use of FinalizationRegistry, which doesn't seem to be supported by React Native yet (see Support FinalizationRegistry in Hermes facebook/hermes#1440).
  • This is the actual error I get when trying a minimal usage of TanstackDB, "ReferenceError: Property 'FinalizationRegistry' doesn't exist, js engine: hermes".
  • There's a reply in that issue (Support FinalizationRegistry in Hermes facebook/hermes#1440 (comment)) saying FinalizationRegistry can be simulated using WeakRef, which is supported on RN.
  • @samwillis mentioned on Discord that FinalizationRegistry is used as an optimization. In the near-term it might be possible to simply disable the optimization when running in RN. Longer-term maybe it's possible to implement a RN friendly optimization, e.g. using WeakRef as mentioned above.

Minimal example here: https://github.com/bsluther/tanstack-db-test

Versions used when I tried this:

"@tanstack/db": "^0.0.5",
"@tanstack/db-collections": "^0.0.7",
"@tanstack/react-db": "^0.0.5",
"expo": "~53.0.11",
"react": "19.0.0",
"react-native": "0.79.3"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions