0

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 {}?

6
  • is that the right way to do it or a hack? just want to learn correctly... Commented Jun 25, 2017 at 16:52
  • thanks Andrew, want to post the answer so I can accept? Commented Jun 25, 2017 at 16:56
  • 1
    Wait, I don't think I read the question right. Are you saying the src variable isn't working? Commented Jun 25, 2017 at 16:58
  • the issue is I can't get rightIcon to render as desired, here is what is happening on the browser: <img src="{currentUserProfile.displayName}" alt="Me" color="#757575" style="height: 24px; width: 24px; display: block; position: absolute; top: 0px; margin: 12px; right: 4px;"> Commented Jun 25, 2017 at 16:59
  • 3
    You shouldn't be making it a string Commented Jun 25, 2017 at 17:00

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.