Commit 46475100 authored by baesangjune's avatar baesangjune
Browse files

sessionstorage

parent 5f3cac18
......@@ -2,19 +2,18 @@ import React from 'react'
import { Link } from 'react-router-dom';
function Home() {
function Home() {
return (
<>
<div classXName="Box">
<div className="Name">
이름을 입력하세요
<input onChange={(event) => sessionStorage.setItem('name',event.target.value)} />
<input onChange={(event) => sessionStorage.setItem('name', event.target.value)} />
</div>
<button onClick={(event) => checking(event)}>이름입력완료</button>
{/* sessionStorage를 사용해야는지 localstorage를 사용해야하는지 */}
</div>
<div className='Box2'>
<Link to="/quiz">
<button className="QuizStart" onClick={checking}>Quiz Start !</button>
......@@ -26,10 +25,12 @@ function Home() {
}
function checking(event) {
if (sessionStorage.getItem('name') === null||sessionStorage.getItem('name').length ===0) {
if (sessionStorage.getItem('name') === null || sessionStorage.getItem('name').length === 0) {
alert('이름을 입력하세요')
// alert('입력하신 이름은'+event.target+'입니다.')
}
else {
alert('입력하신 이름은'+sessionStorage.getItem('name')+'입니다.')
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment