You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627
  1. import { useSelector } from 'state'
  2. import { deepCompareArrays, getPage } from 'utils/utils'
  3. import Shape from './shape'
  4. /*
  5. On each state change, compare node ids of all shapes
  6. on the current page. Kind of expensive but only happens
  7. here; and still cheaper than any other pattern I've found.
  8. */
  9. export default function Page() {
  10. const currentPageShapeIds = useSelector(({ data }) => {
  11. return Object.values(getPage(data).shapes)
  12. .sort((a, b) => a.childIndex - b.childIndex)
  13. .map((shape) => shape.id)
  14. }, deepCompareArrays)
  15. const isSelecting = useSelector((s) => s.isIn('selecting'))
  16. return (
  17. <>
  18. {currentPageShapeIds.map((shapeId) => (
  19. <Shape key={shapeId} id={shapeId} isSelecting={isSelecting} />
  20. ))}
  21. </>
  22. )
  23. }