javascript - Extending style object in react.js -
i'm using react.js , manage of style attributes via react, too. if have a, example, success , error button want apply different background color them.
right now, i'm doing jquery's extend function:
<span style={$.extend({background: 'forestgreen'},this.state.buttonstyle)}></span>
but i'm wondering if there better , maybe more readable solution this. advice?
if use transpiler implements spread property proposal (such babel), can write
style={{...this.state.buttonstyle, background: 'forestgreen'}}
instead.
whether thats "better" or more readable subjective.
Comments
Post a Comment