import React from 'react';
import { View, Text } from 'react-native';
let globalIsTotal =false;
const component = ({ isTotal }) => {
const { mainLabelStyle } = styles;
globalIsTotal = isTotal;
return (
<View>
<Text style={mainLabelStyle}>Hello World</Text>
</View>
);
};
const styles = {
mainLabelStyle: {
fontSize:28,
flex: 1,
fontWeight: () => {
if(globalIsTotal===true){
return 'bold';
}
return 'normal';
}
}
}
I'm trying to set the fontWeight of style depending on globalIsTotal value, but seems like the function is not being trigger. Wondering if this is the right way to handle such styling logic? This is a functional component which is reusable and props isTotal pass from caller