From ef1b5ca153a61f22e875565efe4f1113252a35e6 Mon Sep 17 00:00:00 2001 From: Martin Wighus Holtmon <martinwh@stud.ntnu.no> Date: Fri, 5 Nov 2021 16:07:12 +0100 Subject: [PATCH] projectFirstPart/Problem4 - Removed boud function --- projectFirstPart/p4.jsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/projectFirstPart/p4.jsx b/projectFirstPart/p4.jsx index 20b523e..1e29a01 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> ) } -- GitLab