diff --git a/projectFirstPart/p4.jsx b/projectFirstPart/p4.jsx index 20b523e91f1ca5f12cea251958f84863347de490..1e29a013e42bf87ca57452c445c1ed9557a2b2ef 100644 --- a/projectFirstPart/p4.jsx +++ b/projectFirstPart/p4.jsx @@ -7,12 +7,10 @@ import Header from "./components/header/Header"; class P4 extends React.Component { constructor(props) { super(props); - this.handleButtonClick = this.handleButtonClick.bind(this); this.state = {activePage: States, nextPage: Example} - console.log(this.state.activePage.name) } - handleButtonClick() { + handleButtonClick = () => { this.setState({activePage: this.state.nextPage, nextPage: this.state.activePage}) } @@ -21,7 +19,7 @@ class P4 extends React.Component { <div> <Header /> <button type="button" onClick={this.handleButtonClick}>Switch to {this.state.nextPage.name}</button> - <this.state.activePage/> + <this.state.activePage /> </div> ) }