What's the error here? React styles

// Change code above this line

class Colorful extends React.Component {

render() {

// Change code below this line

const styles = {color: 'purple', fontSize: 40, border: '2px solid purple'};

return (

  <div style={styles}>Style Me!</div>


// Change code above this line



Your code is technically correct, but the challenge wants you to declare the styles object above the render method, not inside of it (see that first line “// Change code above this line”)

It doesn’t let me add it outside the render, above that comment line is still within render, and if it’s declared after trying to use it won’t work either… I don’t know what the issue is here…

There’s a “// Change code above this line” in line 9 and another in line 1. Your style object wants to be above line 1.

1 Like

oh wow… how silly of me… thank you jsdisco.

Blame the challenge setup, I think the style object belongs inside the class, but what do I know about class components in React, they seem as outdated as JavaScript’s var to me.