-1

Below is the part of code of my React App:

<span 
  value={this.props.range}
  style={{width:"{this.props.range}px"}}
  className="range"
></span>

I want to use the value from the props and want to set into style. But I am not getting how to set it.

Emile Bergeron
  • 16,148
  • 4
  • 74
  • 121
Rachit Gupta
  • 59
  • 1
  • 8

1 Answers1

0

Try template strings like this:

<span 
  value={this.props.range}
  style={{width:`${this.props.range}px`}}
  className="range"
></span>
aldenn
  • 1,760
  • 1
  • 8
  • 23