Toggle navigation
Toggle navigation
This project
Loading...
Sign in
박민정
/
We-Shop
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
박민정
2021-06-05 17:01:27 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
42bc1afce1299b0eb73b2631acc9834276314503
42bc1afc
1 parent
7b9ff572
[fix] Fix logout button error
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
3 deletions
boiler-plate/client/src/components/views/LandingPage/LandingPage.js
boiler-plate/client/src/components/views/LandingPage/LandingPage.js
View file @
42bc1af
import
React
,
{
useEffect
}
from
'react'
import
axios
from
'axios'
import
{
withRouter
}
from
'react-router-dom'
;
function
LandingPage
()
{
function
LandingPage
(
props
)
{
// 로그아웃 버튼 클릭 됐을 때
const
onLogoutClickedEvent
=
()
=>
{
axios
.
get
(
'/api/users/logout'
)
.
then
(
response
=>
{
// 만약 success:true이면 로그인 페이지로 가기
if
(
response
.
data
.
success
)
props
.
history
.
push
(
"/login"
);
else
alert
(
"Fail to logout."
)
})
}
// 랜딩페이지에 들어오자마자
useEffect
(()
=>
{
axios
.
get
(
'/api/hello'
)
// get request를 서버로 보냄 (endpoint는 /api/hello)
...
...
@@ -11,11 +24,12 @@ function LandingPage() {
return
(
<
div
style
=
{{
justifyContent
:
'center'
,
alignItems
:
'center'
,
display
:
'flex'
,
width
:
'100%'
}}
>
<
h1
>
시작
페이지
<
/h1
>
<
button
>
Logout
<
/button
>
<
button
onClick
=
{
onLogoutClickedEvent
}
>
Logout
<
/button
>
<
/div
>
)
}
export
default
LandingPage
export
default
withRouter
(
LandingPage
)
\ No newline at end of file
...
...
Please
register
or
login
to post a comment