Skip to content

UsePuck() histories and index do not update with root changes #894

Open
@jwartofsky-yext

Description

@jwartofsky-yext

When using usePuck with histories, the histories and index params do not update when the root data does. However they do when other data is updated.

      <Puck
          config={
            {
              ...puckConfig,
              root: {
                ...puckConfig.root,
                fields: {
                  customField: {
                    label: "The Custom Field",
                    type: "text",
                  }
                },
                defaultProps: {
                  customField: "Custom Field Default"
                },
              }
            }
          }
</Puck>

...
  const {
    appState,
    history: {
      histories,
      index,
    },
  } = usePuck() as {
    appState: ReturnType<typeof usePuck>["appState"];
    history: Omit<ReturnType<typeof usePuck>["history"], "histories"> & {
      histories: History<Partial<AppState>>[];
    };
  };

  useEffect(() => {
    console.log("useEffect called here");
  }, [index, histories]);

When customField is updated, the history and index is not updated. However if another field in puck is updated, then the changes to the customField will be seen in the history along with the other change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions