2

I'm using an inline style to change avatar background-image.

const avatarStyle ={
  backgoundImage: "url('/images/22.jpg')"
};

const avatar() = () => <div style={avatarStyle}></div>

But this code doesn't set any style on this tag.

2
  • 3
    you misspelled background yo, looks fine otherwise Commented Apr 26, 2017 at 17:10
  • Does your <div> have any content, or a fixed height/width? Commented Apr 26, 2017 at 17:11

2 Answers 2

3

You have missed letter r on backgroundImage

I think this will work for you,

const avatarStyle ={
  backgroundImage: "url('/images/22.jpg')"
};

const avatar() = () => <div style={avatarStyle}></div>
Sign up to request clarification or add additional context in comments.

Comments

1

Everything works fine. You just made a typo on line 2. Try this

const avatarStyle ={
  backgroundImage: "url('/images/22.jpg')"
};

const avatar() = () => <div style={avatarStyle}></div>

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.