0

I am trying to display profile images from a list of profiles using the indivdual's profile props but I can not reach the props in the setup for some reason. It works fine for the name and title but when I try to use the profileimage url as source it reads as undefined if I use the example from the answer here React JSX: Access Props in Quotes

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

this does not work for me when used in this code

 <ul className={styles.ListUl}> {this.props.clinicians.map(c => { return ( <li key={c.accountId}> <button onClick={this.handleSetIndividual.bind(this, c)}> <h4>{c.firstName} {c.lastName}</h4> <img src={`${c.profileImageUrl}`} alt="individualImage" height="100" width="100" /> </button> </li> )} )} </ul> 

All other props work such as the names this just has to do with getting the src param access to those props.

using src={c.profileImageUrl} as you suggested was tried already and is read by the browser as absolutely nothing. As in there is no src param any more. like this:

<img alt="profileImage" height="100" width="100"> 

The way I did it src={`${c.profileImageUrl}`} is read as src="undefined" if I take the $ symbol off of it it reads src="c.profileImageUrl"

Thanks in advance for the help!

3
  • What do you mean "this does not work for me"? AKA, what is the specific error that you're getting? Commented Dec 20, 2016 at 19:06
  • 6
    If you console.log(c); before you return, do you see profileImageUrl as a defined property on that object? It could be you have different case or a typo somewhere. Also, you can simplify that image line by making it: <img src={c.profileImageUrl} alt="individualImage" height="100" width="100" /> Commented Dec 20, 2016 at 19:18
  • I updated the question to give you the specific browser issues for each format. Commented Dec 20, 2016 at 19:53

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.