Skip to content

[React19-blog]: Make use(context) example easier to understand - #6783

Merged
rickhanlonii merged 5 commits into
reactjs:mainfrom
Zeko369:fix-theme-example-react19-blog
Apr 25, 2024
Merged

[React19-blog]: Make use(context) example easier to understand#6783
rickhanlonii merged 5 commits into
reactjs:mainfrom
Zeko369:fix-theme-example-react19-blog

Conversation

@Zeko369

Copy link
Copy Markdown
Contributor

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)

@vercel

vercelBot commented Apr 25, 2024

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

NameStatusPreviewCommentsUpdated (UTC)
react-dev🛑 Canceled (Inspect)Apr 25, 2024 9:10pm

@github-actions

github-actionsBot commented Apr 25, 2024

Copy link
Copy Markdown

Size changes

Details

📦 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! 🙌

Comment threadsrc/content/blog/2024/04/25/react-19.md Outdated
Comment threadsrc/content/blog/2024/04/25/react-19.md Outdated
Comment threadsrc/content/blog/2024/04/25/react-19.md Outdated
Comment threadsrc/content/blog/2024/04/25/react-19.md Outdated
Zeko369and others added 4 commits April 25, 2024 23:08
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>

@rickhanloniirickhanlonii left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@vittorioromeo

Copy link
Copy Markdown

How about something simpler that doesn't promote unnecessary mutability?

constcurrentTheme=(theme==='dark') ? DarkThemeContext : LightThemeContext;use(currentTheme);return(<Pagetheme={currentTheme}>{children}</Page>);

Or even inline it in the returned expression.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@Zeko369@vittorioromeo@rickhanlonii@facebook-github-bot