<PLEASE USE THIS TEMPLATE TO HELP YOU CREATE A GREAT POST!>
<Below this line, add a link to the EXACT exercise that you are stuck at.>
<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>
I’ve added the attribute according to the instructions and example, the image changes to a dog when I click it, yet I receive the following error:
“The img should have an attribute of onClick={makeDoggy}.”
Am I missing something here? It seems pretty straightforward, yet here I am.
Code:
var React = require('react');
var ReactDOM = require('react-dom');
function makeDoggy (e) {
// Call this extremely useful function on an <img>.
// The <img> will become a picture of a doggy.
e.target.setAttribute('src', 'https://s3.amazonaws.com/codecademy-content/courses/React/react_photo-puppy.jpeg');
e.target.setAttribute('alt', 'doggy');
}
var kitty = (
<img
src="https://s3.amazonaws.com/codecademy-content/courses/React/react_photo-kitty.jpg"
alt="kitty"
onClick={makeDoggy}
/>
);
ReactDOM.render(kitty, document.getElementById('app'));