React Native inline styles and performance

前端 未结 2 1940
日久生厌
日久生厌 2020-12-31 01:49

Does the following:


Have any performance implications compared to:

&         


        
2条回答
  •  渐次进展
    2020-12-31 02:23

    From the docs for StyleSheet

    Performance:

    • Making a stylesheet from a style object makes it possible to refer to it by ID instead of creating a new style object every time.
    • It also allows to send the style only once through the bridge. All subsequent uses are going to refer an id (not implemented yet).

    Another benefit is that style errors will be generated at compile time as opposed to run time.

    I personally still like using inline styles (and creating new components for shared styles) because it makes the code more readable for me and the performance hit has not been noticeable.

提交回复
热议问题