You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not sure if this is a bug or a misunderstanding. As part of learning Suspense and using it in a project, I was puzzled by the behavior of useDeferredValue. When using it, my component seemed to use the deferred value until the new UI state was unsuspended/done rendering, regardless of the timeoutMs parameter.
I forked the Code Sandbox linked from the Concurrent UI Patterns to try and distill the problem. First, when using useDeferredValue in the child component, the timeoutMs does have the expected effect, when using either version of React. But then, when I moved the use of useDeferredValue higher to the App component to match how I was using it, the behavior differed. When using 0.0.0-experimental-5faf377df, it does have an effect. But in the most recent react@experimental, 0.0.0-experimental-4ead6b530, it no longer has an effect.
functionApp(){const[resource,setResource]=useState(initialResource);constdeferredResource=useDeferredValue(resource,{timeoutMs: 42// Doesn't appear to be making a difference in the latest React});constisPending=deferredResource!==resource;return(<><buttondisabled={isPending}onClick={()=>{// startTransition(() => {constnextUserId=getNextId(resource.userId);setResource(fetchProfileData(nextUserId));// });}}>
Next
</button>{isPending ? " Loading..." : null}<ProfilePageresource={deferredResource}isStale={deferredResource!==resource}/></>);}functionProfilePage({ resource, isStale }){return(<Suspensefallback={<h1>Loading profile...</h1>}><ProfileDetailsresource={resource}/><Suspensefallback={<h1>Loading posts...</h1>}><ProfileTimelineresource={resource}isStale={isStale}/></Suspense></Suspense>);}
The text was updated successfully, but these errors were encountered:
React version: 0.0.0-experimental-4ead6b530
ReactDOM version: 0.0.0-experimental-4ead6b530
Steps To Reproduce
I'm not sure if this is a bug or a misunderstanding. As part of learning Suspense and using it in a project, I was puzzled by the behavior of useDeferredValue. When using it, my component seemed to use the deferred value until the new UI state was unsuspended/done rendering, regardless of the
timeoutMs
parameter.I forked the Code Sandbox linked from the Concurrent UI Patterns to try and distill the problem. First, when using useDeferredValue in the child component, the
timeoutMs
does have the expected effect, when using either version of React. But then, when I moved the use ofuseDeferredValue
higher to theApp
component to match how I was using it, the behavior differed. When using0.0.0-experimental-5faf377df
, it does have an effect. But in the most recentreact@experimental
,0.0.0-experimental-4ead6b530
, it no longer has an effect.The text was updated successfully, but these errors were encountered: