Open NeRo8 opened 2 years ago
I have dumb component, and for getting access to colors I must use EStyleSheet.value.
const DumbComponent = () => { const [isActive, setActive] = useState(false); //Current realisation const activeBackground = EStyleSheet.value('$red'); const disabledBackground = EStyleSheet.value('$blue'); return ( <BumbElement color={isActive ? activeBackground : disabledBackground} /> ); };
But can we put inside EStyleSheet.create custom object with colors what we need, and after use it in our component?
EStyleSheet.create
const styles = EStyleSheet.create({ colors: { red: '$red', blue: '$blue', }, contentContainerStyle: { flexDirection:'row' } }); const DumbComponent = () => { const [isActive, setActive] = useState(false); return <BumbElement color={styles.colors[isActive ? 'red' : 'blue']} />; };
I have dumb component, and for getting access to colors I must use EStyleSheet.value.
But can we put inside
EStyleSheet.create
custom object with colors what we need, and after use it in our component?