Commit 9f71e384 authored by Nate Wienert's avatar Nate Wienert Committed by GitHub

fix: use deferred value to avoid suspense issues with inputting text (#6996)

fix: use deferred value to avoid suspense issues with inputting text during supsended render causing errors
parent 8592a4a5
import usePrevious from 'hooks/usePrevious' import React, { Suspense, useDeferredValue } from 'react'
import React, { Suspense } from 'react'
/** /**
* This is useful for keeping the "last rendered" components on-screen while any suspense * This is useful for keeping the "last rendered" components on-screen while any suspense
...@@ -9,6 +8,7 @@ import React, { Suspense } from 'react' ...@@ -9,6 +8,7 @@ import React, { Suspense } from 'react'
*/ */
export const SuspenseWithPreviousRenderAsFallback = (props: { children: React.ReactNode }) => { export const SuspenseWithPreviousRenderAsFallback = (props: { children: React.ReactNode }) => {
const previousContents = usePrevious(props.children) const previousChildren = useDeferredValue(props.children)
return <Suspense fallback={previousContents ?? null}>{props.children}</Suspense>
return <Suspense fallback={previousChildren ?? null}>{props.children}</Suspense>
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment