Replies: 3 comments 3 replies
-
Interesting findings!
The library is evolving all the time. If I hadn't gone fully native, I would have happily convert current solution to The current implementation meets the needs of 99% of developers. I understand that, with a large codebase, it might produce overhead in rendering. You can simply fork the repository for the next few weeks and patch it with I will be happy to give you early beta access of 3.0 to test it with such large codebase. I hope it will resolve all the issues mentioned by you. |
Beta Was this translation helpful? Give feedback.
-
Hey, that's really affecting me, I'm using unistyles everywhere in the app and changing theme or orientation is very very slow |
Beta Was this translation helpful? Give feedback.
-
Most apps will have a tab navigator that's always mounted which causes switching themes in unistyles to be very slow in even medium sized project |
Beta Was this translation helpful? Give feedback.
-
Hello!
Firstly, I love your lib and is currently kicking NativeWind and switching to Unistyles.
Secondly, considering I'm working on a big scale app with my own atom components that I reuse EVERYWHERE, I have A LOT of useStyles hooks that are being created.
Now, I got stuck on what you said on Discord about useContext & useState being the same.
So, to silence the VOICES, I went and tested it.
Test: Rendering 1000 views that each have their own useStyles hook.
Screenshot 1: The current implementation of useStyles using a localized useState and a subscription to an event for every useStyles called
Screenshot 2: Added a theme provider at the root with a useState variable that tracks the theme and modified the useStyles hook to use useContext instead
The results shows that the current way and the useContext way have some differences:
The initial render time is the same, which is REALLY good! But, changing the theme (and maybe even the other values like the insets and width/height) is slower with the current implementation compared to useContext.
I suspect that, adding a subscription and it's own local state variable to each components adds a lot of overhead when anything from the useStyles hook changes (mainly if your design pattern causes lots of useStyles hooks being used).
I know that V3 is in the works and will do some beautiful voodoo magic with the ShadowTree to do no rerenders, but for the time being, wouldn't converting to useContext be better for the layout, insets and theme changes?
Related repos:
The test
The fork where I changes for using useContext in useStyles hook(I only changed what was necessary for the test, so all the other things like UnistylesRuntime.themeName or UnistylesRuntime.setTheme do nothing and are not in sync with the context value)
Beta Was this translation helpful? Give feedback.
All reactions