4. React Lifecycle Methods
Activity 4.01: Creating a Messaging App
Solution:
- Start off by creating a new React project and take a look at the browser window that should have opened for you automatically:
$ npx create-react-app ajax-simulation $ cd ajax-simulation $ yarn start
- Next, strip out the stuff we don't need. Delete
src/logo.svg
and delete the contents ofsrc/App.css
. Clean out the contents of theApp
component and replace it with a class component instead. Since we are using a class component here, we will need to change theimport
statement at the top toimport {Component} from React
:import React, { Component } from 'react'; import "./App.css"; Â Â Â Â class App extends Component { Â Â Â Â Â Â render() { Â Â Â Â Â Â Â Â return ( Â Â Â Â Â Â Â Â Â Â <div className="App">Messaging App</div> Â Â ...