There is a button at the bottom that when I click I want it to change the background color of the pink containers. How do I make it work, linking the button to the container?
import ListCar from './ListCar';
import {useState} from 'react';
export default function App() {
const [color, setColor] = useState(true);
const toggle=()=>{
setColor(!color);
}
return
<StatusBar style="light"/>
<View style={{ maxheight:10, backgroundColor: "lightgrey" }}>
<Button onPress={toggle} classname={'container'} title="Change Background"></Button>
</View>
</SafeAreaView>
);
}
export default ListCar = (props) => {
return(
<View style={styles.container}>
<View>
<Image source={require("./bmw.jpg")} style={{width:150, height:150, resizeMode:'contain'}}/>
)
}
const styles = StyleSheet.create({
container:{
backgroundColor: 'pink',
marginTop: 20,
flexDirection: 'row',
padding:5,
},