The journey to becoming a developer

My future is created by what I do today, not tomorrow.

What I learned/CodeSquad Log

CodeSquad Day 78 : Team Project 2 - Day 8

Millie 2022. 4. 28. 00:51

 

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

 

'What I learned > CodeSquad Log' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

CodeSquad Day 80 : Team Project 2 - Day 10  (0) 2022.04.29
CodeSquad Day 77 : Team Project 2 - Day 7  (0) 2022.04.28
CodeSquad Day 76 : Team Project 2 - Day 6  (0) 2022.04.26
CodeSquad Day 75 : Team Project 2 - Day 5  (0) 2022.04.22
CodeSquad Day 74 : Team Project 2 - Day 4  (2) 2022.04.21