jaredh159 / tailwind-react-native-classnames

simple, expressive API for tailwindcss + react-native

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

useDeviceContext triggers re render too often

EliasGit117 opened this issue · comments

Because of changing app's size it triggers re render on each pixel size that has been changed. This sounds not really performant, can be something done with it?

are you targeting RN Web? in native environments (which is all this library aims to support), resize don't happen very often, usually only on orientation change, so it's not much of an issue. it's not like on the web where the user might grab the corner of a screen and drag to resize.

@jaredh159 okay, but in case if use it on web too, is there a way to fix it?

not something simple that's readily available in the library. you could probably add some of your own code to debounce window resize events and then possibly call into the device context somehow to re-render less frequently, but you'd have to implement that yourself, and i don't think it would be trivial. sorry. :/ once again, it's just not the use case this library is targeting, so we don't have a good answer built-in.

Well, unistyles added debounce system.

jpudysz/react-native-unistyles@b015d7b

cool! maybe you could use that as an inspiration for building your own debounce wrapper for twrnc. until we change to also support RN Web, it's not something we'll be adding to the library itself. 👍