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
|
|
|
|
2021-07-03 16:30:06 +00:00
|
|
|
export default function useShape(id: string) {
|
2021-06-26 11:52:36 +00:00
|
|
|
return useSelector(
|
2021-06-29 12:00:59 +00:00
|
|
|
(s) => tld.getShape(s.data, id),
|
2021-07-03 16:30:06 +00:00
|
|
|
(prev, next) =>
|
|
|
|
!(
|
2021-06-26 11:52:36 +00:00
|
|
|
prev &&
|
|
|
|
next &&
|
|
|
|
next !== prev &&
|
|
|
|
getShapeUtils(next).shouldRender(next, prev)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|