CodeSquad Day 78 : Team Project 2 - Day 8
CodeSquad๐นDay 78
'๋ชจ๋ ์นดํ ๊ณ ๋ฆฌ ๋ณด๊ธฐ' ๋ฒํผ ๊ตฌํ
์คํ 2์๋ถํฐ 5์ 30๋ถ๊น์ง๋ ํ๋์ ํจ๊ป ํ์ด ํ๋ก๊ทธ๋๋ฐ์ผ๋ก ์ฝ๊ฐ์ ๋ฆฌํฉํ ๋ง ๋ฐ ๊ธฐ๋ฅ๊ตฌํ์ ํ๋ค. ๋ชจ๋ ์นดํ ๊ณ ๋ฆฌ ๋ณด๊ธฐ ๋ฒํผ์ state๋ก ๊ตฌํํ๋ ์ ๋ง ๊ฐ๋จํ๊ฒ ๊ตฌํํ ์ ์์๋ค.
import React, { useState } from 'react';
import { MainWrapper, AllCategoryBtn } from './Main.style.js';
import categoryTitleData from 'data/categoryTitle';
import Slider from 'components/Slider/Slider.jsx';
const Main = () => {
const [visibleIdx, setVisibleIdx] = useState(0);
const [isBtnAvailable, setIsBtnAvailable] = useState(true);
const handleAllCategoryBtnClick = () => {
setVisibleIdx(categoryTitleData.length - 1);
setIsBtnAvailable(false);
};
return (
<MainWrapper>
{categoryTitleData.map((v, i) => {
return <Slider key={i} title={v.name} id={v.id} display={i <= visibleIdx ? 'block' : 'none'} />;
})}
{isBtnAvailable && <AllCategoryBtn onClick={handleAllCategoryBtnClick}>๋ชจ๋ ์นดํ
๊ณ ๋ฆฌ ๋ณด๊ธฐ</AllCategoryBtn>}
</MainWrapper>
);
};
export default Main;
categoryTitleDate๋ฅผ map์ ๋๋ ค์ Slider๋ฅผ ๋ง๋ค์ด ์ฃผ๊ณ ์๋ค. ๋ฒํผ์ ๋๋ฅด๊ธฐ ์ ์๋ visibleIdx์ ๊ฐ์ 0์ผ๋ก ์ด๊ธฐํ๋์ด ์๊ธฐ ๋๋ฌธ์ display๋ฅผ ๋ณด๋ฉด i๊ฐ 0์ ์ด๊ณผํ๋ฉด display: 'none'์ด ๋์ด ๋ณด์ด์ง ์๋๋ค. ์ฆ ๋งจ ์ฒ์ Slider๋ง ๋ ธ์ถ์ด ๋๊ณ ๊ทธ ๋ค์ Slider๋ค์ ํ๋ฉด์ ๋ณด์ด์ง ์๋๋ค.
๋ฒํผ์ ํด๋ฆญํ๊ฒ ๋๋ฉด setVisibleIdx ํจ์๋ก visibleIdx๋ฅผ categoryTitleDate์ ๊ธธ์ด์์ 1์ ๋บ ๋งํผ์ผ๋ก ์ค์ ํด์ค๋ค. ๊ทธ๋ฌ๋ฉด display์ ๋น๊ต์์ ๋ชจ๋ ๋ง์กฑํ๊ฒ ๋๋ฏ๋ก display: 'block'์ด ๋์ด์ ๋ชจ๋ Slider๊ฐ ๋ ๋๋ง์ด ๋ ์ ์๊ฒ ๋๋ค.
๊ธฐ๋ฅ ๊ตฌํ ํ ๊ตฌํ์ํฉ, ์ง๋ฌธ๊ฑฐ๋ฆฌ ๋ฑ์ ์ ์ด PR๋ ๋ณด๋๋ค.
๋ก๊ทธ์ธ ๊ธฐ๋ฅ ๊ตฌํ ์๋
์คํ 7์ ๋ฐ๋ถํฐ 10์๊น์ง๋ Github ๊ณ์ ์ผ๋ก ๋ก๊ทธ์ธ์ ์๋ํด ๋ณด๋ ค๊ณ ํ๋ค. ๊ทธ ๊ณผ์ ์์ ์ฝ๋์ค์ฟผ๋ ๋ฐ๋ก ์ง์ ๊ธฐ์ ๋ถ์ธ Tami์ ๋ธ๋ก๊ทธ ๊ธ์ด ๋งค์ฐ ๋์๋์๋ค.
[React] OAuth Github ๋ก๊ทธ์ธ ๊ตฌํํ๊ธฐ
์ ๋ถํฐ ๋๋ฌด๋๋ ํด๋ณด๊ณ ์ถ์๋ ๊นํ๋ธ OAuth ๋ก๊ทธ์ธ์ ์ฑ๊ณต์ ์ผ๋ก ๊ตฌํํ๋ค. ๊ตฌํ๋จ๊ณ์ ๋ฐฉ๋ฒ์ ์ค๋ช ํด๋ณผ ์์ ! ๐ ํ๋ก์ ํธ ๊ตฌ์ฑ * React ํจ์ํ ์ปดํฌ๋ํธ (jsx) ๋ฐฉ์์ผ๋ก ๊ตฌํํ ํ๋ก์ ํธ์ ๋๋ค!
rrecoder.tistory.com
์ ๋ง ์ ๋ฆฌ๋ฅผ ์ ํด๋์ผ์ ์ ๋ง์ ์ฐธ๊ณ ๊ฐ ๋์๋ค.
React Authentication with Twitter, Google, Facebook and Github
In a previous post, I went over an approach you could take to authenticate your React app with Twitter. The obvious next step is to add…
codeburst.io
๋ก๊ทธ์ธ ๋ ํ์ ์ฐฝ์ ๋ง๋ค์ด์ผ ํ๋๋ฐ, ๋ชจ๋ฌ์ฐฝ์ด ์๋ ์ฃผ์์ฐฝ์ด ์กด์ฌํ๋ ํ์ ์ฐฝ์ ์ด๋ป๊ฒ ๋์ฐ๋์ง ๋ชฐ๋ผ์ ๊ตฌ๊ธ๋ง์ ํ๊ณ ์์ ๊ฐ์ ๋งํฌ๋ฅผ ์ฐพ์๋ค. window API๋ฅผ ํ์ฉํ๋ ๊ฒ์ด์๋ค.
const openPopup = () => {
const width = 600;
const height = 800;
const left = window.innerWidth / 2 - width / 2;
const top = window.innerHeight / 2 - height / 2;
const url = `${API_URL}`;
return window.open(
url,
'',
`toolbar=no, location=no, directories=no, status=no, menubar=no,
scrollbars=no, resizable=no, copyhistory=no, width=${width},
height=${height}, top=${top}, left=${left}`
);
};
์์ ๊ฐ์ด window ๊ฐ์ฒด์ open ๋ฉ์๋๋ฅผ ํ์ฉํด ์ธ์๋ก ๊ฐ์ ๋๊ฒจ์ฃผ๊ฒ ๋๋ฉด ํ์ ์ฐฝ์ด ์ ๋จ๊ฒ ๋๋ค.
๊ทธ๋ฆฌ๊ณ react-router-dom์ ์ฌ์ฉํ๊ธฐ ์ํด์ ์ค์น๋ฅผ ํ๋๋ฐ Switch ์ปดํฌ๋ํธ๋ฅผ ์ฌ์ฉํ ์ ์์๋ค. ์๊ณ ๋ณด๋ 6๋ฒ์ ์์๋ ๋ฌธ๋ฒ์ด ์ฝ๊ฐ ๋ฌ๋ผ์ก๋ค. ์๋ stackoverflow์ ๊ธ์ ๋ณด๊ณ ๊ณ ์น ์ ์์๋ค.
Attempted import error: 'Switch' is not exported from 'react-router-dom'
I don't know why I am getting this error and I can't find an answer for it anywhere. I have uninstalled the react-router-dom package and reinstalled it, but it continues to tell me that the switch ...
stackoverflow.com