Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
online-quiz-react
Commits
46475100
Commit
46475100
authored
Jul 29, 2020
by
baesangjune
Browse files
sessionstorage
parent
5f3cac18
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/Home.js
View file @
46475100
...
...
@@ -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
'
)
+
'
입니다.
'
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment