reactjs - how to set inline style in react jsx -


i trying apply inline styles in react component follows. right way set styles, if not how can achieve this?

  <div     {...customprops}     style={{ width: `${widthvalue}%`,       animationdelay: `${animationdelay}s`,       zindex: `${zindex}`,       animation: `loadbar ${incrementvalue}s linear forwards`}}     key={i}     classname={`well-background--${group.concept}       well-groupedprogressbar--progress       well-groupedprogressbar--${props.heightsize}`}   />, 

thanks

you need pass obj inline styles attribute. code correct, can clean code preparing style object in render function if changing everytime like

render() {     var style = {       width: `${widthvalue}%`,       animationdelay: `${animationdelay}s`,       zindex: `${zindex}`,       animation: `loadbar ${incrementvalue}s linear forwards`     }     return (         <div            {...customprops}            style={style}            key={i}            classname={`well-background--${group.concept}                         well-groupedprogressbar--progress                        well-groupedprogressbar--${props.heightsize}`                       }           />      ) } 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -