You get a bonus - 1 coin for daily activity. Now you have 1 coin

How do you access Props inside attribute quotes?

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:
  1. < img  className = ' image '  src = { ` images / $ { this . props . image } ` } />

Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Scripting client side JavaScript, jqvery, BackBone"

Terms: Scripting client side JavaScript, jqvery, BackBone