changed to class components in frontend

This commit is contained in:
Joshua Hsueh 2021-01-30 15:45:46 -05:00
parent 71214d9900
commit fab1eb94a2
5 changed files with 94 additions and 20 deletions

View File

@ -1,5 +1,5 @@
{ {
"name": "reinvest", "name": "reinvest-frontend",
"version": "0.1.0", "version": "0.1.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,

View File

@ -1,8 +1,26 @@
import React from "react"; import React, { Component } from "react";
import "./assets/Bank.css"; import "./assets/Bank.css";
const Bank = (props) => { class Bank extends Component {
return <h1>Bank page</h1>; constructor(props) {
}; super(props);
this.state = { apiResponse: "" };
}
callAPI() {
fetch("http://localhost:9000/FETCHURL")
.then((res) => res.text())
.then((res) => this.setState()({ apiresponse: res }))
.catch((err) => err);
}
componentDidMount() {
this.callAPI();
}
render() {
return (
<div class="container">
<h1 class="d-flex justify-content-center m-2 p-4">Bank</h1>
</div>
);
}
}
export default Bank; export default Bank;

View File

@ -1,8 +1,27 @@
import React from "react"; import React, { Component } from "react";
import "./assets/Browse.css"; import "./assets/Browse.css";
const Browse = (props) => { class Browse extends Component {
return <h1>landing page</h1>; constructor(props) {
}; super(props);
this.state = { apiResponse: "" };
}
callAPI() {
fetch("http://localhost:9000/FETCHURL")
.then((res) => res.text())
.then((res) => this.setState()({ apiresponse: res }))
.catch((err) => err);
}
componentDidMount() {
this.callAPI();
}
render() {
return (
<div class="container">
<h1 class="d-flex justify-content-center m-2 p-4">Browse</h1>
</div>
);
}
}
export default Browse; export default Browse;

View File

@ -1,8 +1,27 @@
import React from "react"; import React, { Component } from "react";
import "./assets/Portfolio.css"; import "./assets/Portfolio.css";
class Portfolio extends Component {
const Portfolio = (props) => { constructor(props) {
return <h1>homepage</h1>; super(props);
}; this.state = { apiResponse: "" };
}
callAPI() {
fetch("http://localhost:9000/FETCHURL")
.then((res) => res.text())
.then((res) => this.setState()({ apiresponse: res }))
.catch((err) => err);
}
componentDidMount() {
this.callAPI();
}
render() {
return (
<div class="container">
<h1 class="d-flex justify-content-center m-2 p-4">Portfolio</h1>
<h1>{this.state.apiResponse}</h1>
</div>
);
}
}
export default Portfolio; export default Portfolio;

View File

@ -1,8 +1,26 @@
import React from "react"; import React, { Component } from "react";
import "./assets/Profile.css"; import "./assets/Profile.css";
class Profile extends Component {
const Profile = (props) => { constructor(props) {
return <h1>Profile page</h1>; super(props);
}; this.state = { apiResponse: "" };
}
callAPI() {
fetch("http://localhost:9000/FETCHURL")
.then((res) => res.text())
.then((res) => this.setState()({ apiresponse: res }))
.catch((err) => err);
}
componentDidMount() {
this.callAPI();
}
render() {
return (
<div class="container">
<h1 class="d-flex justify-content-center m-2 p-4">Profile</h1>
</div>
);
}
}
export default Profile; export default Profile;