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

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

Merged
merged 5 commits into from
Apr 25, 2024

Conversation

Zeko369
Copy link
Contributor

@Zeko369 Zeko369 commented Apr 25, 2024

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)

Copy link

vercel bot commented Apr 25, 2024

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

Name Status Preview Comments Updated (UTC)
react-dev 🛑 Canceled (Inspect) Apr 25, 2024 9:10pm

Copy link

github-actions bot commented Apr 25, 2024

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

Zeko369 and 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>
Copy link
Member

@rickhanlonii rickhanlonii left a comment

Choose a reason for hiding this comment

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

Thanks!

@rickhanlonii rickhanlonii merged commit 9afcbf6 into reactjs:main Apr 25, 2024
5 checks passed
@vittorioromeo
Copy link

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.

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

Successfully merging this pull request may close these issues.

4 participants