score:1

Accepted answer
class Child extends React.Component {
 render(){
  const {styles} = this.props
  return (
   <div>
    <Child className={styles.field} />
   </div>
  )
}

score:0

// Parent component 
class Parent extends React.Component {
 render(){
  return (
   <View>
    <Child customStyle={styles.childStyle} />
   </View>
  )
}
}

const styles = StyleSheet.create({
 childStyle: {
   color: "red"
 }
});

// Child component

class Child extends React.Component {
  render () {
    return (    
    <View>
        <Text style={[this.props.customStyle, styles.text]}></Text>
      </View>
    )
  }
}

const styles = StyleSheet.create({
  text: {
    fontSize: 14
  }
});

score:0

import React from "react";
import { Text, View } from "react-native";

const ChildComponent = (props) => {
  return <Text style={props.style}>{props.data}</Text>;
};

export default ChildComponent;


Related Query

More Query from same tag