Skip to content

Commit

Permalink
docs(examples): update create-react-app example (#4347)
Browse files Browse the repository at this point in the history
  • Loading branch information
wdwang09 committed Apr 20, 2022
1 parent be3d7f0 commit 1f03a44
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion examples/create-react-app-example/src/App.js
@@ -1,4 +1,5 @@
import React, { useState, useEffect } from 'react';
import logo from './logo.svg';
import './App.css';
import io from 'socket.io-client';

Expand All @@ -23,7 +24,7 @@ function App() {
socket.off('disconnect');
socket.off('message');
};
});
}, []);

const sendMessage = () => {
socket.emit('hello!');
Expand All @@ -32,9 +33,21 @@ function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>Connected: { '' + isConnected }</p>
<p>Last message: { lastMessage || '-' }</p>
<button onClick={ sendMessage }>Say hello!</button>
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
);
Expand Down

0 comments on commit 1f03a44

Please sign in to comment.