You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Others might run into this problem so I figured I might as well post the code inside the Client/Apps.js file that I used to get things working.
If you're starting a new React project, you're going to start with a function inside Client/App.js called, App(). This needs to be replaced by Render() and moved into App class. Please see below:
importReact,{Component}from'react'importlogofrom'./logo.svg';import'./App.css';classAppextendsReact.Component{constructor(props){super(props);this.state={apiResponse: ""};}callAPI(){fetch("http://localhost:9000/testAPI").then(res=>res.text()).then(res=>this.setState({apiResponse: res}));}componentDidMount(){this.callAPI();}render(){return(<divclassName="App"><headerclassName="App-header"><imgsrc={logo}className="App-logo"alt="logo"/><p>
Edit <code>src/App.js</code> and save to reload.
</p><aclassName="App-link"href="https://reactjs.org"target="_blank"rel="noopener noreferrer">
Learn React
</a></header><pclassName="App-intro">{this.state.apiResponse}</p></div>);}}exportdefaultApp;
The text was updated successfully, but these errors were encountered:
Others might run into this problem so I figured I might as well post the code inside the Client/Apps.js file that I used to get things working.
If you're starting a new React project, you're going to start with a function inside Client/App.js called,
App()
. This needs to be replaced byRender()
and moved intoApp
class. Please see below:The text was updated successfully, but these errors were encountered: