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

前端 未结 3 1364
盖世英雄少女心
盖世英雄少女心 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:40

    Please have a look on https://github.com/vitalets/react-native-extended-stylesheet#underscored-styles

    Style created via extended stylesheet contains original values in underscored prop:

    const styles = EStyleSheet.create({
      text: {
        fontSize: '1rem',
        color: 'gray'
      }
    });
    

    In runtime:

    styles = {
      text: 0,
      _text: {
        fontSize: 16,
        color: 'gray'
      }
    }
    

提交回复
热议问题