Skip to content

Commit 92c27f7

Browse files
authored
Merge pull request Team-Shaka#106 from Team-Shaka/FE-80
fix: 뷰에 따른 Selectbar.js 조건 수정
2 parents e5e3df7 + b4638df commit 92c27f7

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

breifing/src/components/aboutComps/Header.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const Header = () => {
5858
</svg>
5959
</button>
6060
</div>
61-
<div className="visible xs:invisible text-primaryBgColor font-bold text-lg cursor-pointer">
61+
<div onClick={() => navigate("/")} className="visible xs:invisible text-primaryBgColor font-bold text-lg cursor-pointer">
6262
Briefing
6363
</div>
6464
<div>
@@ -81,7 +81,7 @@ const Header = () => {
8181
</div>
8282
<div className="opacity-0">dfsdfsdfdfs</div>
8383
</div>
84-
{location.pathname === "/" ? <SelectBar /> : null}
84+
<SelectBar />
8585

8686
<div
8787
className={cls(

breifing/src/components/aboutComps/SelectBar.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,22 @@ import React, { useState } from 'react';
22
import { useRecoilState } from 'recoil';
33
import { categoryState } from '../../recoil/atoms/categoryState';
44
import { cls } from './Header';
5+
import { useLocation, useNavigate, useParams } from 'react-router-dom';
56

67
const texts = ["전체", "사회", "글로벌", "경제", "과학"]
78
const SelectBar = () => {
89
const [category, setCategory] = useRecoilState(categoryState)
10+
const navigate = useNavigate();
11+
const { pathname } = useLocation()
12+
913

1014
const onClickBtn = (text) => {
1115
setCategory(text)
12-
16+
navigate("/")
1317
}
1418

1519
return (
16-
<div className='xs:border-t xs:border-b border-[#B6B6B6] p-3'>
20+
<div className={cls('xs:border-t xs:border-b border-[#B6B6B6] p-3 ', pathname === "/" ? "" : "hidden xs:block")}>
1721
<div className='flex justify-center space-x-5 xs:space-x-20 text-sm'>
1822
{texts.map((text, i) => <div onClick={() => onClickBtn(text)} className={cls('cursor-pointer hover:font-bold transition-all', category === text ? "font-bold" : "")} key={i}>{text}</div>)}
1923
</div>

0 commit comments

Comments
 (0)