Home.js 2.11 KB
Newer Older
JeongYeonwoo's avatar
updated    
JeongYeonwoo committed
1
2
3
import React, { useState } from 'react'
import { Redirect } from 'react-router-dom';
import './Home.css'
4
5

function Home() {
JeongYeonwoo's avatar
updated    
JeongYeonwoo committed
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
    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)
        }
    }

24
25
    return (
        <>
JeongYeonwoo's avatar
updated    
JeongYeonwoo committed
26
            {done ? <Redirect to='/quiz' /> : ''}
JeongYeonwoo's avatar
JeongYeonwoo committed
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
           <div className="d-flex justify-content-center ">
            <table className="table table-borderless" style={{width : "500px"}}>
                <thead className="text-center">
                    <tr  style={{height:"180px"}}></tr>
                </thead>
                <tbody className="text-center">
                    <tr>
                        <td>이름 입력<input className="ml-2 inputBox" onChange={handleChange} /></td>
                    </tr>
                    <tr>
                        <td>비밀번호<input className="ml-2 inputBox" onChange={handleChange} /></td>
                    </tr>
                    <tr>
                        <td><button className="mt-4 btn btn-dark" onClick={checking}>Quiz Start !</button></td>
                    </tr>
                </tbody>
            </table>
            </div>
            {/* 
                    <div className="container-fluid">
                        <div className="text-center">
                            <div>
                                이름을 입력하세요
JeongYeonwoo's avatar
JeongYeonwoo committed
50
                    </div>
JeongYeonwoo's avatar
JeongYeonwoo committed
51
52
53
54
55
56
                            <input className="inputBox" onChange={handleChange} />
                            <div className='Box2'>
                                <button className="btn btn-dark" onClick={checking}>Quiz Start !</button>
                            </div>
                        </div>
                    </div> */}
JeongYeonwoo's avatar
updated    
JeongYeonwoo committed
57

JeongYeonwoo's avatar
JeongYeonwoo committed
58
            <div>계산수학</div>
59
        </>
JeongYeonwoo's avatar
updated    
JeongYeonwoo committed
60
61
    )
}
62
export default Home;