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

[Typo]: In Sharing State Between Components #7001

Open
farhadjaman opened this issue Jun 29, 2024 · 2 comments · May be fixed by #7007
Open

[Typo]: In Sharing State Between Components #7001

farhadjaman opened this issue Jun 29, 2024 · 2 comments · May be fixed by #7007

Comments

@farhadjaman
Copy link

Summary

When explaining state lifting up, there's a small error in the example function for the second step : Pass hardcoded data from the common parent:

function Panel({ title, children, isActive }) {
  return (
    <section className="panel">
      <h3>{title}</h3>
      {isActive ? (
        <p>{children}</p>
      ) : (
        <button onClick={() => setIsActive(true)}>
          Show
        </button>
      )}
    </section>
  );
}

The onClick calls setIsActive, but since there's no state declared, it should be removed.

Page

https://react.dev/learn/sharing-state-between-components

Details

No response

@rickhanlonii
Copy link
Member

Yeah, it seems like step two could also add the onShow as a prop. It still wouldn't work, but it would flow into step three of passing the props down from the parent. Do you want to submit a PR that adds an onShow prop and passes an empty function from the parent?

@farhadjaman
Copy link
Author

farhadjaman commented Jun 29, 2024

yes, I want to add a PR. Can you assign it to me?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants