Perf: memoize AggregateKeyframeEditor

This commit is contained in:
Aria Minaei 2022-07-12 12:10:52 +02:00 committed by Aria
parent b37ccb1e4e
commit 558882ff0a

View file

@ -60,26 +60,24 @@ export type IAggregateKeyframeEditorProps = {
* is open. This would require having some kind of stable identity for each aggregate row. * is open. This would require having some kind of stable identity for each aggregate row.
* Let's defer that work until other interactive keyframe editing PRs are merged in. * Let's defer that work until other interactive keyframe editing PRs are merged in.
*/ */
const AggregateKeyframeEditor: React.VFC<IAggregateKeyframeEditorProps> = ( const AggregateKeyframeEditor: React.VFC<IAggregateKeyframeEditorProps> =
props, React.memo((props) => {
) => { const utils = useAggregateKeyframeEditorUtils(props)
const utils = useAggregateKeyframeEditorUtils(props) return (
<AggregateKeyframeEditorContainer
return ( style={{
<AggregateKeyframeEditorContainer top: `${props.viewModel.nodeHeight / 2}px`,
style={{ left: `calc(${val(
top: `${props.viewModel.nodeHeight / 2}px`, props.layoutP.scaledSpace.leftPadding,
left: `calc(${val( )}px + calc(var(--unitSpaceToScaledSpaceMultiplier) * ${
props.layoutP.scaledSpace.leftPadding, utils.cur.position
)}px + calc(var(--unitSpaceToScaledSpaceMultiplier) * ${ }px))`,
utils.cur.position }}
}px))`, >
}} <AggregateKeyframeDot editorProps={props} utils={utils} />
> <AggregateKeyframeConnector editorProps={props} utils={utils} />
<AggregateKeyframeDot editorProps={props} utils={utils} /> </AggregateKeyframeEditorContainer>
<AggregateKeyframeConnector editorProps={props} utils={utils} /> )
</AggregateKeyframeEditorContainer> })
)
}
export default AggregateKeyframeEditor export default AggregateKeyframeEditor