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

Support unistyles provider with no breaking changes #337

Merged
merged 3 commits into from
Nov 22, 2024

Conversation

yousefelgoharyx
Copy link
Contributor

@yousefelgoharyx yousefelgoharyx commented Nov 11, 2024

Summary

The current version of Unistyles has a big performance hit in projects where useStyles hook is used a lot as described in this discussion #240

This PR implements the solution mentioned by the author of the discussion but without any breaking changes. You can opt in by adding UnistylesProvider at the root of your app to get a huge performance gain

Thanks to the author of the discussion for such a brilliant workaround

Copy link

vercel bot commented Nov 11, 2024

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

Name Status Preview Comments Updated (UTC)
react-native-unistyles-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 17, 2024 3:06pm

@dhruvpvx
Copy link

Are you saying we can use unistyles without prebuilding?

Copy link
Owner

@jpudysz jpudysz left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, I will try to play around with it 🙏🏼

src/context.tsx Outdated Show resolved Hide resolved
src/hooks/useUnistyles.ts Show resolved Hide resolved
@jpudysz
Copy link
Owner

jpudysz commented Nov 15, 2024

@yousefelgoharyx ping, can you fix the syntax?

Copy link
Owner

@jpudysz jpudysz left a comment

Choose a reason for hiding this comment

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

Lint reported some issues

examples/expo/src/examples/TwoThemesWithProviderScreen.tsx Outdated Show resolved Hide resolved
examples/expo/src/examples/TwoThemesWithProviderScreen.tsx Outdated Show resolved Hide resolved
examples/expo/src/examples/index.ts Outdated Show resolved Hide resolved
src/context.tsx Outdated Show resolved Hide resolved
src/hooks/useUnistyles.ts Show resolved Hide resolved
src/context.tsx Outdated Show resolved Hide resolved
src/context.tsx Show resolved Hide resolved
@jpudysz
Copy link
Owner

jpudysz commented Nov 22, 2024

Testing now

@jpudysz
Copy link
Owner

jpudysz commented Nov 22, 2024

Changing 1000 boxes with useStyles hook:

  • With Provider: 500-800ms

  • Without Provider: 4.5 - 5.1 s

What a change!!

@yousefelgoharyx
Copy link
Contributor Author

yousefelgoharyx commented Nov 22, 2024

Letsss gooo 🚀🚀🔥🔥

@jpudysz jpudysz merged commit 829290b into jpudysz:main Nov 22, 2024
3 checks passed
@jpudysz jpudysz mentioned this pull request Nov 22, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants