-
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
[React19-blog]: Make use(context) example easier to understand #6783
[React19-blog]: Make use(context) example easier to understand #6783
Conversation
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! 🙌 |
Co-authored-by: Ricky <rickhanlonii@gmail.com>
Co-authored-by: Ricky <rickhanlonii@gmail.com>
Co-authored-by: Ricky <rickhanlonii@gmail.com>
Co-authored-by: Ricky <rickhanlonii@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
How about something simpler that doesn't promote unnecessary mutability? const currentTheme = (theme === 'dark') ? DarkThemeContext : LightThemeContext;
use(currentTheme);
return (
<Page theme={currentTheme}>
{children}
</Page>
); Or even inline it in the returned expression. |
Current example was defining a local variable with the same name as the prop which was had to understand (also technically it's a runtime error)