ignite-bowser
ignite-bowser copied to clipboard
Why dont use styleSheet.create in styling screen?
Hi team, i saw the project generated by ignite bowser use style like:
const CONTAINER: ViewStyle = {
backgroundColor: color.transparent,
...
}
Its perfomance not better than:
const styles = StyleSheet.create({
container: {
backgroundColor: color.transparent,
...
},
});
So why we dont use StyleSheet?
Ok, no one reply. And i found the result: at rn 0.57 or bellow, we should use StyleSheet for improve perfomance. But now from 0.6x no diffirent between create style using plain object and StyleSheet. So still use plain object. Reference: https://stackoverflow.com/questions/38958888/react-native-what-is-the-benefit-of-using-stylesheet-vs-a-plain-object
Thanks for the followup. I was wondering that myself.
Hi team, i saw the project generated by ignite bowser use style like:
const CONTAINER: ViewStyle = { backgroundColor: color.transparent, ... }
Its perfomance not better than:
const styles = StyleSheet.create({ container: { backgroundColor: color.transparent, ... }, });
So why we dont use StyleSheet?
As @vantuan88291 mentioned, there is no performance benefit to using the Stylesheet API. The reason we don't use it is because we find that it is more verbose to type.
It's much easier to type a style object like this:
const CONTAINER: ViewStyle = {
...styles
}