Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: only pass props to top level #63

Merged
merged 1 commit into from
Sep 10, 2021
Merged

fix: only pass props to top level #63

merged 1 commit into from
Sep 10, 2021

Conversation

dpilch
Copy link
Member

@dpilch dpilch commented Sep 10, 2021

  • only apply props spread to top level

This was done by adding a StudioNode object that contain the current component as well as a reference to the parent node.

Example props not spread:

export default function CollectionOfCustomButtons(props) {
  const { width, backgroundColor, buttonColor } = props;
  const filterCriteriabuttonUser = [];
  const { buttonUser } = useDataStoreBinding({
    type: "collection",
    model: User,
    criteria: filterCriteriabuttonUser,
  });
  return (
    <Collection
      type="list"
      gap="1.5rem"
      backgroundColor={backgroundColor}
      items={buttonUser}
      {...props}
      {...getOverrideProps(props.overrides, "Collection")}
    >
      {(item, index) => (
        <Flex {...getOverrideProps(props.overrides, "Collection.Flex")}>
          <Button
            label={item.username || "hspain@gmail.com"}
            labelWidth={width}
            backgroundColor={buttonColor.favoriteColor}
            disabled={isDisabled}
            {...getOverrideProps(props.overrides, "Collection.Flex.Button")}
          ></Button>
        </Flex>
      )}
    </Collection>
  );
}

Set correct path for getOverrideProps

Resolves #58
@frimfram frimfram merged commit 5e59d9b into main Sep 10, 2021
@dpilch dpilch deleted the spread-props-fix branch September 14, 2021 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nested components shouldn't receive {...props} and should accurately create overrideProps string
2 participants