2021-06-26 11:52:36 +00:00
|
|
|
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
|
|
|
import { useSelector } from 'state'
|
|
|
|
import { getShapeUtils } from 'state/shape-utils'
|
2021-06-29 12:00:59 +00:00
|
|
|
import tld from 'utils/tld'
|
2021-06-26 11:52:36 +00:00
|
|
|
|
|
|
|
export default function useShapeDef(id: string) {
|
|
|
|
return useSelector(
|
2021-06-29 12:00:59 +00:00
|
|
|
(s) => tld.getShape(s.data, id),
|
2021-06-26 11:52:36 +00:00
|
|
|
(prev, next) => {
|
|
|
|
const shouldSkip = !(
|
|
|
|
prev &&
|
|
|
|
next &&
|
|
|
|
next !== prev &&
|
|
|
|
getShapeUtils(next).shouldRender(next, prev)
|
|
|
|
)
|
|
|
|
|
|
|
|
return shouldSkip
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|