Skip to content

useTracker and concurrent mode/suspense #336

Open
@OliverColeman

Description

@OliverColeman

Just wondering how or if it's possible to integrate React Suspense with useTracker. The documentation about useTracker mentions Suspense integration, but I can find no examples of this. I think the Suspense API requires data loaders to throw a promise when data is loading (?), and after a quick scan of the useTracker code it looks like useTracker itself doesn't do this, so perhaps it's not possible out of the box?

Activity

CaptainN

CaptainN commented on Jul 12, 2021

@CaptainN
Contributor

useTracker supports suspense in that it will work, and properly clean up in suspended scenarios. The same goes for error boundaries and concurrent mode. It doesn't support throwing promises though, for a bunch of complexity reasons. Basically, computations are very flexible, and there are a lot of edge cases to consider.

It should be fairly straight forward to use a separate hook though. Meteor.subscribe supports a callback in it's use. You could tie that to a Promise and throw it, and use it that way to get suspense. Then use useTracker only for your queries.

CaptainN

CaptainN commented on Jul 12, 2021

@CaptainN
Contributor

BTW, useTracker without deps array might "just work" with suspense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in-discussionWe are still discussing how to solve or implement it

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @CaptainN@filipenevola@OliverColeman

        Issue actions

          useTracker and concurrent mode/suspense · Issue #336 · meteor/react-packages