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

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

25
26
    return (
        <>
JeongYeonwoo's avatar
updated    
JeongYeonwoo committed
27
28
29
30
31
32
33
34
35
36
37
            {done ? <Redirect to='/quiz' /> : ''}
            <div style={{ backgroundImage: 'url(' + bg + ')', backgroundColor: "grey", backgroundSize: "100%", width: "100%", height: "880px", backgroundRepeat: 'no-repeat' }}>
                {/* <div className="Main"></div> */}

                <div className="container">
                    <div className="text-center">
                        이름을 입력하세요
                        <input className="inputBox" onChange={handleChange} />
                        <div className='Box2'>
                            <button className="btn btn-dark" onClick={checking}>Quiz Start !</button>
                        </div>
JeongYeonwoo's avatar
JeongYeonwoo committed
38
                    </div>
JeongYeonwoo's avatar
updated    
JeongYeonwoo committed
39
                    {/* localStorage를 사용해야는지 localstorage를 사용해야하는지 */}
JeongYeonwoo's avatar
JeongYeonwoo committed
40
41
                </div>

JeongYeonwoo's avatar
updated    
JeongYeonwoo committed
42
43
44
                <div>계산수학</div>


45
46
47
48
49
            </div>
        </>



JeongYeonwoo's avatar
updated    
JeongYeonwoo committed
50
    )
51

JeongYeonwoo's avatar
updated    
JeongYeonwoo committed
52
}
53
export default Home;
JeongYeonwoo's avatar
updated    
JeongYeonwoo committed
54