Skip to content

Instantly share code, notes, and snippets.

@jetaggart
Created July 12, 2020 22:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jetaggart/d9a2388c31e224e3f003061dd9de373d to your computer and use it in GitHub Desktop.
Save jetaggart/d9a2388c31e224e3f003061dd9de373d to your computer and use it in GitHub Desktop.
// frontend/src/App.js:7
function App() {
const [firstName, setFirstName] = useState('');
const [lastName, setLastName] = useState('');
const [email, setEmail] = useState('');
// We'll get to these in a bit
const [chatClient, setChatClient] = useState(null);
const [channel, setChannel] = useState(null);
async function register() {
// ...
}
if (chatClient && channel) {
// ...
} else {
return (
<div className="app">
<div className="app-input">
<label htmlFor="firstName">First Name</label>
<input type="text" name="firstName"
value={firstName}
onChange={(e) => setFirstName(e.target.value)}
/>
</div>
<div className="app-input">
<label htmlFor="lastName">Last Name</label>
<input type="text" name="lastName"
value={lastName}
onChange={(e) => setLastName(e.target.value)}
/>
</div>
<div className="app-input">
<label htmlFor="email">Email</label>
<input type="text" name="email"
value={email}
onChange={(e) => setEmail(e.target.value)}
/>
</div>
<button onClick={() => register()}>Start Chat</button>
</div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment