Home.js 1.28 KB
Newer Older
JeongYeonwoo's avatar
JeongYeonwoo committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import React, { useState } from 'react'
import { Redirect } from 'react-router-dom';
import './Home.css'

function Home() {
    const [name, setName] = useState('')
    const [done, setDone] = useState(false)

    const handleChange = (event) => {
        setName(event.target.value)
    }

    function checking(event) {
        if (!name) {
            alert('이름을 입력하세요')
        }
        else {
            alert('입력하신 이름은' + name + '입니다.')
            localStorage.setItem('name', name)
            setDone(true)
        }
    }

    return (
        <>
            {done ? <Redirect to='/quiz' /> : ''}
            <div className="container-fluid">
                <div className="text-center">
                    <div>
                        이름을 입력하세요
                    </div>
                    <input className="inputBox" onChange={handleChange} />
                    <div className='Box2'>
                        <button className="btn btn-dark" onClick={checking}>Quiz Start !</button>
                    </div>
                </div>
                {/* localStorage를 사용해야는지 localstorage를 사용해야하는지 */}
            </div>

            <div>계산수학</div>



        </>



    )

}
export default Home;