Skip to content

Commit

Permalink
#2
Browse files Browse the repository at this point in the history
  • Loading branch information
guilherme-toti committed Feb 8, 2018
1 parent 703cbc3 commit 374d7ed
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion src/App.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,47 @@
import React, { Component } from 'react';
import './App.css';

class MyButton extends Component {
render() {
return (
<button
onClick={() => { this.props.handleClick(this.props.label); }}
>
{this.props.label}
</button>
);
}
}

class MyLabel extends Component {
render() {
return <p>Cliquei no: {this.props.text}</p>
}
}


class App extends Component {
constructor(props) {
super(props);

this.state = {
labelText: '',
};
}

setLabelText = (labelText) => {
this.setState({ labelText });
}

render() {
return (
<p>Hello, World, Teste!</p>
<div className="App">
<MyLabel text={this.state.labelText} />
<MyButton handleClick={this.setLabelText} label="Botão 1" />
<MyButton handleClick={this.setLabelText} label="Botão 2" />
<MyButton handleClick={this.setLabelText} label="Botão 3" />
<MyButton handleClick={this.setLabelText} label="Botão 4" />
</div>
);
}
}
Expand Down

0 comments on commit 374d7ed

Please sign in to comment.