react.dev
react.dev copied to clipboard
Please carefully look up to this here as setIsActive is not defined yet but called inside code at line 163
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
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Updated (UTC) |
---|---|---|---|
react-dev | ✅ Ready (Inspect) | Visit Preview | Feb 25, 2024 10:21am |
Size changes
📦 Next.js Bundle Analysis for react-dev
This 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?
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?
@KishorKumarParoi how about you update the PR with these changes then?
Updated Thank you
Hope this one is going to be merged soon