-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Please carefully look up to this here as setIsActive is not defined yet but called inside code at line 163 #6657
base: main
Are you sure you want to change the base?
Conversation
…at line 163, isActive is only passing by props from Accordion, I know that what I did it's not best solution,I added this lines for proper understanding and updated setIsActive to setCheckActive to remove errors, Please take necessary steps so that learners like myself don't get confused by ReferenceError of variables which isn't declared yet and got curious about why it was like that
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Size changes📦 Next.js Bundle Analysis for react-devThis analysis was generated by the Next.js Bundle Analysis action. 🤖 This PR introduced no changes to the JavaScript bundle! 🙌 |
Hey there @KishorKumarParoi! 👋 The error in this code is intentional. It's showing the second step of a 3-step refactoring to lift state up. That said, I agree that this may be confusing. Perhaps it would be a good idea to add a comment next to the confusing code? Something like this: function Panel({ title, children, isActive }) {
return (
<section className="panel">
<h3>{title}</h3>
{isActive ? (
<p>{children}</p>
) : (
<button onClick={() => setIsActive(true)}>
// 👆 This onClick handler doesn't work yet, because we removed setIsActive in step 1
Show
</button>
)}
</section>
);
} What do you think? |
Yes I am agreed with you |
@KishorKumarParoi how about you update the PR with these changes then? |
Updated Thank you |
Hope this one is going to be merged soon |
Please carefully look up to this here setIsActive is not defined yet at line 163, isActive is only passing by props from Accordion, I know that what I did it's not best solution,I added this lines for proper understanding and updated setIsActive to setCheckActive to remove errors, Please take necessary steps so that learners like myself don't get confused by ReferenceError of variables which isn't declared yet and got curious about why it was like that