AnApprentice
AnApprentice

Reputation: 110960

Within React, how to have a variable within a variable?

I have the following:

      <MenuItem
        primaryText={currentUserProfile.displayName || currentUserProfile.email}
        onTouchTap={this.handleTouchTap}
        leftIcon={<DropDownArrow color={textColor}/>}
        rightIcon={<img src="{currentUserProfile.displayName}" alt="Me" />}
        style={{color: textColor}}
      />

The rightIcon is not working as it is already within a {} --- how do I get a variable to work within a {}?

Upvotes: 0

Views: 39

Answers (1)

vee_ess
vee_ess

Reputation: 699

You are specifying your URL as "{currentUserProfile.displayName}" as a string literal. You should be using rightIcon={<img src={currentUserProfile.displayName} alt="Me" />}

EDIT: Notice your quotation marks.

Upvotes: 2

Related Questions