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.

page.tsx 677B

12345678910111213141516171819202122232425
  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. return (
  16. <>
  17. {currentPageShapeIds.map((shapeId) => (
  18. <Shape key={shapeId} id={shapeId} />
  19. ))}
  20. </>
  21. )
  22. }