Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Dynamic Styles In React Native


export default function App() {
  const [r, setR] = useState(true);

  
    return (
    <View style={styles.container}>

<TouchableOpacity style={[styles.button, {backgroundColor: r? "blue":"yellow"}]}>
<Text style={{color:  r? "black":"blue"}}>
 Invoke Fancy Button
  </Text>

</TouchableOpacity> 

    </View>
  );
}

/*keep in mind you must keep your dynamic styling separate from your static stuff*/
 
PREVIOUS NEXT
Tagged: #Dynamic #Styles #In #React #Native
ADD COMMENT
Topic
Name
3+9 =