Passing Styles Based on Parent Component in React Native

前端 未结 2 1716
野趣味
野趣味 2021-01-24 17:27

I have a component that is being passed a style so..

TextFile.js:

 
  This is a li         


        
2条回答
  •  Happy的楠姐
    2021-01-24 17:55

    In my initial TextFile, I passed style as an argument, and in the styles array, just used style as the second item in the array.

    const TextFile = ({ text, style }) => (
        {text} 
    );
    

    Whenever TextFile gets used, it will apply any styles being given within that component, and/or default to the initial styles it's being given in styles.text.

    Thank you @Li357!

提交回复
热议问题