Practice
React (or JSX) does not support variable interpolation inside an attribute value. The markup shown below will not work:
<img className='image' src='images/{this.props.image}' />
But you can put any JS expression inside curly braces as the complete attribute value. So the expression below does work:
<img className='image' src={'images/' + this.props.image} />
Using template strings will also work:
< img className = ' image ' src = { ` images / $ { this . props . image } ` } />
Comments