Published on

React - useTransition() vs useDeferredValue()

Authors

React - useTransition() vs useDeferredValue()

React - useTransition() vs useDeferredValue()

When Should You Use Which?

The difference is that useTransition() wraps the state updating code, whilst useDeferredValue() wraps a value that's affected by the state update. You don't need to (and shouldn't) use both together, since they achieve the same goal in the end.

Instead, it makes sense to prefer useTransition(), if you have some state update that should be treated with a lower priority and you have access to the state updating code. If you don't have that access, use useDeferredValue().