Perf-gain: memoize the sequence editor panel's dims to avoid unnecessary re-renders
This commit is contained in:
parent
667f9d4fa2
commit
bac27777c4
1 changed files with 11 additions and 4 deletions
|
@ -1,4 +1,4 @@
|
||||||
import {val} from '@theatre/dataverse'
|
import {prism, val} from '@theatre/dataverse'
|
||||||
import {usePrism} from '@theatre/react'
|
import {usePrism} from '@theatre/react'
|
||||||
import type {UIPanelId} from '@theatre/shared/utils/ids'
|
import type {UIPanelId} from '@theatre/shared/utils/ids'
|
||||||
import type {$IntentionalAny, VoidFn} from '@theatre/shared/utils/types'
|
import type {$IntentionalAny, VoidFn} from '@theatre/shared/utils/types'
|
||||||
|
@ -108,13 +108,20 @@ const BasePanel: React.FC<{
|
||||||
const width = Math.max(right - left, minDims.width)
|
const width = Math.max(right - left, minDims.width)
|
||||||
const height = Math.max(bottom - top, minDims.height)
|
const height = Math.max(bottom - top, minDims.height)
|
||||||
|
|
||||||
const stuff: PanelStuff = {
|
// memo-ing dims so its ref can be used as a cache key
|
||||||
dims: {
|
const dims = prism.memo(
|
||||||
|
'dims',
|
||||||
|
() => ({
|
||||||
width,
|
width,
|
||||||
left,
|
left,
|
||||||
top,
|
top,
|
||||||
height,
|
height,
|
||||||
},
|
}),
|
||||||
|
[width, left, top, height],
|
||||||
|
)
|
||||||
|
|
||||||
|
const stuff: PanelStuff = {
|
||||||
|
dims: dims,
|
||||||
panelId,
|
panelId,
|
||||||
minDims,
|
minDims,
|
||||||
boundsHighlighted,
|
boundsHighlighted,
|
||||||
|
|
Loading…
Reference in a new issue