tldraw/hooks/useShape.ts
2021-06-29 13:00:59 +01:00

20 lines
500 B
TypeScript

/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { useSelector } from 'state'
import { getShapeUtils } from 'state/shape-utils'
import tld from 'utils/tld'
export default function useShapeDef(id: string) {
return useSelector(
(s) => tld.getShape(s.data, id),
(prev, next) => {
const shouldSkip = !(
prev &&
next &&
next !== prev &&
getShapeUtils(next).shouldRender(next, prev)
)
return shouldSkip
}
)
}