Skip to content

Commit

Permalink
setState
Browse files Browse the repository at this point in the history
  • Loading branch information
15Dkatz committed Oct 19, 2022
1 parent d8399e1 commit a28a72f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions portfolio/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@ import React, { Component } from 'react';
class App extends Component {
constructor() {
super();
this.state = { displayBio: true };
this.state = { displayBio: false };

console.log('Component this', this);

this.toggleDisplayBio = this.toggleDisplayBio.bind(this);
}

toggleDisplayBio() {
this.setState({ displayBio: !this.state.displayBio });
}

render() {
Expand All @@ -18,8 +26,13 @@ class App extends Component {
<p>I live in San Francisco, and code every day.</p>
<p>My favorite language is JavaScript, and I think React.js is awesome</p>
<p>Besides coding, I also love music and ramen!</p>
<button onClick={this.toggleDisplayBio}>Show less</button>
</div>
) : (
<div>
<button onClick={this.toggleDisplayBio}>Read more</button>
</div>
) : null
)
}
</div>
);
Expand Down

0 comments on commit a28a72f

Please sign in to comment.