Home.js 1.38 KB
Newer Older
김민수's avatar
김민수 committed
1
2
import React, { useState } from 'react'
import { Redirect } from 'react-router-dom';
김민수's avatar
김민수 committed
3
import './Home.css'
김민수's avatar
김민수 committed
4
import bg from './img_study.jpg'
김민수's avatar
김민수 committed
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28


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' /> : ''}
김민수's avatar
김민수 committed
29
30
            <div className="Main">
            {/* <div className="Main"></div> */}
김민수's avatar
김민수 committed
31
32

                <div className="Box">
김민수's avatar
김민수 committed
33
                    <div className="Name">
김민수's avatar
김민수 committed
34
                        이름을 입력하세요
김민수's avatar
김민수 committed
35
                        <input className="input-style" onChange={handleChange} />
김민수's avatar
김민수 committed
36
                        <div className='Box2'>
김민수's avatar
김민수 committed
37
                            <button className="QuizStart" onClick={checking}>Quiz Start !</button>
김민수's avatar
김민수 committed
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
                        </div>
                    </div>
                    {/* localStorage를 사용해야는지 localstorage를 사용해야하는지 */}
                </div>

                <div>계산수학</div>


            </div>
        </>

    )
}

export default Home;