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

chore: added hook and removed theme provider #2150

Closed
wants to merge 3 commits into from

Conversation

ferreroltd
Copy link
Contributor

following pattern from docs

Copy link

vercel bot commented May 17, 2024

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

5 Ignored Deployments
Name Status Preview Comments Updated (UTC)
alpha-docs ⬜️ Ignored (Inspect) Visit Preview 💬 Add feedback May 17, 2024 3:17pm
marmalade-marketplace ⬜️ Ignored (Inspect) Visit Preview May 17, 2024 3:17pm
proof-of-us ⬜️ Ignored (Inspect) Visit Preview May 17, 2024 3:17pm
react-ui ⬜️ Ignored (Inspect) Visit Preview May 17, 2024 3:17pm
tools ⬜️ Ignored (Inspect) Visit Preview May 17, 2024 3:17pm

Copy link

changeset-bot bot commented May 17, 2024

⚠️ No Changeset found

Latest commit: 326712d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

* overwriteTheme can be used when you want 1 particular component to have a fixed theme
* IMPORTANT: this will also overwrite the lockedTheme for that component
*/
overwriteTheme?: ITheme;
Copy link
Collaborator

Choose a reason for hiding this comment

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

As far as I can see, the theme is applied at the application level. How can you set it at the component level?

/**
* lockedTheme will lock the theme for the whole application.
* It will overwrite the localstorage and even the switching of themes in your system will not update the theme
* IMPORTANT: using the useTheme twice in a application can lead to unexpected race conditions
Copy link
Collaborator

Choose a reason for hiding this comment

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

But you already used the useThem twice! once in the Layout component and once in Providers which causes the issue.
I think the better way is splitting the hook to the Provider and the hook, to avoid this kind of issues.
So the setting up the theme will be handled in the Provider (So basically all useEffects)
and useTheme will be used to read/set data from/to context.

@ferreroltd
Copy link
Contributor Author

This will be re-done using the hook coming from react-ui lib #2137

@ferreroltd ferreroltd closed this May 22, 2024
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.

None yet

2 participants