Search
 
SCRIPT & CODE EXAMPLE
 

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*/
Comment

react native dynamic style

//you can use a function to generate a styleSheet dynamically
styleFunction (option) {
  return {
    borderWidth: 2,
    margin: option,
  }
}

<View style={this.styleFunction(15)}>
	//things
</View>
Comment

PREVIOUS NEXT
Code Example
Javascript :: what is let js 
Javascript :: audio get current time 
Javascript :: input type for mobile number in react js 
Javascript :: add multiple images inside the DOM js 
Javascript :: js get smallest value of array 
Javascript :: mdn javascript 
Javascript :: bs modal service angular pass data 
Javascript :: react-native-geolocation-service 
Javascript :: the event object 
Javascript :: set active element javascript 
Javascript :: js upload file size limit 
Javascript :: react.createref 
Javascript :: && in javascript 
Javascript :: eliminar duplicados javascript 
Javascript :: find the second largest number in array javascript 
Javascript :: fizzbuzz in one line javascript 
Javascript :: JSON parse error: Cannot deserialize value of type `java.util.Date` from String 
Javascript :: display array javascript 
Javascript :: is javascript loosely typed 
Javascript :: can we pass variable to a object 
Javascript :: KeyboardDatePicker background color 
Javascript :: function l(){return window.performance 
Javascript :: jquery-3.5.1.min.js download 
Python :: python tkinter window fullscreen 
Python :: save a dict to pickle 
Python :: sort dataframe by column 
Python :: python RuntimeError: tf.placeholder() is not compatible with eager execution. 
Python :: delete pycache files 
Python :: python kivy Kivy files require #:kivy ! 
Python :: python open mat file 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =