Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useTransition support #191

Open
samdenty opened this issue Apr 11, 2021 · 0 comments
Open

useTransition support #191

samdenty opened this issue Apr 11, 2021 · 0 comments

Comments

@samdenty
Copy link
Owner

samdenty commented Apr 11, 2021

useTransition is the hook that allows for non flashy UI transitions.

Currently facebook/react#17199 means it's impossible to detect during render whether a component has a useTransition, and whether or not it's pending.

Somehow we need to signal to the gqless react binding not to throw a promise (both hook & HoC), when it's pending, AKA:

const { something } = useQuery();
const [startTransition, isPending] = unstable_useTransition({
	timeoutMs: 3000
});

if (isPending) {
  doNotThrowPromiseAndJustRenderWithOldData()
}

This should uphold the concurrent mode guarantees, at least for loading states.

ways I can think of to do this:

  • gqless provides it's own wrapped useTransition
    • this won't work with third-party libraries that use the real one
  • gqless overwrites useTransition and inserts logic to check for the pending state
    • we would need to do this at the start of the application, import("@gqless/react").enableTransitions() (would be graceful)
@samdenty samdenty added concurrent-mode enhancement New feature or request feature discussion and removed enhancement New feature or request feature labels Apr 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant