Access props inside quotes in React JSX

后端 未结 9 1213
广开言路
广开言路 2020-12-04 06:11

In JSX, how do you reference a value from props from inside a quoted attribute value?

For example:



        
9条回答
  •  长情又很酷
    2020-12-04 06:32

    Best practices are to add getter method for that :

    getImageURI() {
      return "images/" + this.props.image;
    }
    
    
    

    Then , if you have more logic later on, you can maintain the code smoothly.

提交回复
热议问题