obipawan / react-native-dash

A super simple <Dash /> component for react-native to draw customisable dashed lines
176 stars 63 forks source link

improve performance #4

Closed garthenweb closed 7 years ago

garthenweb commented 7 years ago

For every dash in the component, a new style was created and thus and a new object is allocated in memory which also has to be sent over the native bridge. This is a performance intensive task and may lead to jank.

See https://facebook.github.io/react-native/docs/stylesheet.html for further information.

This commit introduces the use of StyleSheet.create to create reusable styles and stores them by an id to reference them later for dashes with the same styling.

I tried to align as much as possible on the rules used in your project but there was no .eslintrc or something else to align on, I hope this matches your preferences.

obipawan commented 7 years ago

Lovely! thanks a ton for the optimisations 👍