How do we access props in attribute quotes?

Answer

React (or JSX) doesn't support variable interpolation inside an attribute value.
<img className='image' src='images/{this.props.image}' />
But we can put any JS expression inside curly braces as the entire attribute value.
So the below expression works:

<img className='image' src={'images/' + this.props.image} />
Using template strings will also work:

<img className='image' src={`images/${this.props.image}`} />

All react js Questions

Ask your interview questions on react-js

Write Your comment or Questions if you want the answers on react-js from react-js Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---