Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the object in StyleSheet.create?(React Native)

const styles = StyleSheet.create({

    container : {
        flex : 1,
        backgroundColor : config.getColor('bg'),
    },
    title : {
        marginLeft : 80,
        marginTop : 30,
        height : 35,
        width : 100,
        borderRadius : 17,
        borderWidth : 1,
        borderColor : config.getColor('theme'),
        fontSize : 17,
        color : config.getColor('theme')
    }
});

when I console.log styles.title,I got a number.so how to convert it to a object?

like image 283
Hai . Z Avatar asked Nov 29 '22 23:11

Hai . Z


1 Answers

You can use the flatten method.

Example:

StyleSheet.flatten(styles.title)
like image 80
Jean Regisser Avatar answered Dec 04 '22 10:12

Jean Regisser