javascript - How to change ReactJS styles dynamically? -
i trying run reactjs inside twitter bootstrap web app. have issues using styles.
having div:
... <div class="ui-progressbar-value ui-widget-header ui-corner-left" style="width: 80%;"/> ...
i'm writing dynamic progress bar, , make 80% change (look @ ** underneath). code writing in jsx:
var task = react.createclass({ render: function() { return ( <li> <a href="#"> <span classname="header"> <span classname="title">{this.props.type}</span> <span classname="percent">{this.props.children}%</span> </span> <div classname="taskprogress progressslim progressblue" > <div classname="ui-progressbar-value ui-widget-header ui-corner-left" **style="width"+{this.props.value} +"%;" />** </div> </a> </li> ); } });
i read documentation inline sytles, example light.
thanks help.
edit:
by using:
style={{width : this.props.children}}
it works fine, wondering how force % instead of px.
ok, found solution.
probably due lack of experience reactjs , web development...
var task = react.createclass({ render: function() { var percentage = this.props.children + '%'; .... <div classname="ui-progressbar-value ui-widget-header ui-corner-left" style={{width : percentage}}/> ...
i created percentage variable outside in render function.
Comments
Post a Comment