Skip to content

"Advanced Topics > Context" regarding component composition source code and description do not match #1706

Closed
@GasimGasimzada

Description

@GasimGasimzada

I am going to copy the bits here:

One way to solve this issue without context is to pass down the Avatar component itself so that the intermediate components don't need to know about the user prop:

The text before this talks about user and avatarSize but the text only mentions user prop. Additionally, the Page component in the snippet below uses user and avatarSize props. The usage code shows only user prop being passed to Page component (sorry removed comments from the snippet as I am currently translating the comments and copied it from currently working localization repo).

function Page(props) {
  const user = props.user;
  const userLink = (
    <Link href={user.permalink}>
      <Avatar user={user} size={props.avatarSize} />
    </Link>
  );
  return <PageLayout userLink={userLink} />;
}

<Page user={user} />

<PageLayout userLink={...} />

<NavigationBar userLink={...} />

{props.userLink}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions