Get CSS property values from a component's “style” prop

前端 未结 3 1374
盖世英雄少女心
盖世英雄少女心 2021-02-19 06:12

I\'m writing a React Native component for a library and I want users to be able to style it using the style property, just like React.View and other bu

3条回答
  •  情话喂你
    2021-02-19 06:49

    You need to import StylesheetRegistry:

    StyleSheetRegistry = require("../../node_modules/react-native/Libraries/StyleSheet/StyleSheetRegistry"),
    

    Then pass in the style ID:

    var style = StyleSheetRegistry.getStyleByID(this.props.style)
    

提交回复
热议问题