首页 > 解决方案 > ReactJS dont take the css styles

问题描述

Technology :

Todo :

Tried Case :

 onClick={this.handleClick} style={this.state.currentPage === number ?
 styles.paginationButtons : [styles.paginationButtons,
 {backgroundColor:'blue'}]}>

标签: javascriptcssreactjs

解决方案


Try updating your code so that you supply the dynamic styles to your component without the use of arrays.

You should be able to do so in this way:

style={ (this.state.currentPage === number ? styles.paginationButtons : { backgroundColor:'blue', ...styles.paginationButtons }) }

推荐阅读