Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

How to change color of an icon, text or other component with ReactNative useState Hook

function MyComponent= () => {
    const [defaultcolor, setNewColor] = useState('white')
    return (
        <View>
            <TouchableOpacity style={styles.MyRoundButtonStyle} onPress={() => 
                  setColor('green')} >
                <Ionicons name="heart" size={50} color={defaultcolor} />
            </TouchableOpacity>
        </View>
)};

export default MyComponent;
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #How #change #color #text #component #ReactNative #useState #Hook
ADD COMMENT
Topic
Name
2+5 =