Z
Z
zhodino2018-09-03 16:48:54
React
zhodino, 2018-09-03 16:48:54

How to add one property to styles object?

const styles = {
  inputInit: {
     display: 'flex',
     justifyContent: 'center',
     flexDirection: 'row',
     alignItems: 'center',
     height: 60,
     padding: 20,
     border: '1px solid red',
     cursor: 'pointer',
  },
};

How to add just one property? If I write like this, then all styles disappear
<div style={[{backgroundColor: 'green'}, styles.inputInit]}>
        {this.value}
   </div>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2018-09-03
@zhodino

<div style={{ ...styles.inputInit, backgroundColor: 'green' }}>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question