Skip to content

Instantly share code, notes, and snippets.

@cnocon
Created September 1, 2020 22:41
Show Gist options
  • Select an option

  • Save cnocon/6d98b1eaaa4f6c0fd6f9a5c0df0b30e5 to your computer and use it in GitHub Desktop.

Select an option

Save cnocon/6d98b1eaaa4f6c0fd6f9a5c0df0b30e5 to your computer and use it in GitHub Desktop.

Revisions

  1. Cristin O'Connor created this gist Sep 1, 2020.
    20 changes: 20 additions & 0 deletions useState-answer.jsx
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    import React, { useState } from 'react';

    function App() {
    const [ score, setScore ] = useState(0);
    const [ message, setMessage ] = useState('Welcome!');

    return (
    <div className="App">
    <header className="App-header">
    <h1>{ message }</h1>
    <h2>{ score }</h2>
    <button onClick={() => setScore(prevScore => prevScore + 1)}>
    Increase score
    </button>
    </header>
    </div>
    )
    };

    export default App;