12. State Management with Hooks
Activity 12.01: Creating a Chat App Using Hooks
Solution:
- Start off by creating a new React app:
$ npx create-react-app chat-windows
- Go to the
src/App.js
file and deletelogo.svg
. - Replace the contents of
src/App.css
with the following:.App { Â Â margin: 20px; } button { Â Â width: 200px; Â Â height: 50px; Â Â background: #4444ff; Â Â color: white; Â Â font-weight: bold; Â Â border: none; Â Â cursor: pointer; Â Â margin: 5px; }
- Replace the contents of
src/App.js
to get an empty component to work with:import React from "react"; import "./App.css"; const App = () => { Â Â return ( Â Â Â Â <div className="App"> Â Â Â Â <button>Add Chat Window</button> Â Â Â Â </div> Â Â ); }; export default App;
The first thing we want to do is start to build out...