scrimba
Interview questions
Miscellaneous (but important!) Questions
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

To see this lesson you need to be logged in. Joining Scrimba is free and gives you access to 20+ courses.Sign up
Miscellaneous (but important!) Questions
AboutCommentsNotes
Miscellaneous (but important!) Questions
Expand for more info
index.js
run
preview
console
import React from 'react'; 
import ReactDOM from 'react-dom';

class Counter extends React.Component {
constructor() {
super();

this.state = {
count: 0
};
}

render() {
return (
<div>
<button onClick={() => {
this.setState({ count: this.state.count - 1 });
}}>-</button>
{this.state.count}
<button onClick={() => {
this.setState({ count: this.state.count + 1 });
}}>+</button>
</div>
);
}
}

const domElement = document.getElementById('root')

ReactDOM.render(<Counter />, domElement)
Console
/index.html
-7:49