Skip to content

๐Ÿ“‹ React TodoList ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ - ์ตœ์ ํ™”

Notifications You must be signed in to change notification settings

greedy-team/react-todo-list

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

18 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“‹React To-do List

๐Ÿค” ํ•™์Šต ์ž๋ฃŒ์˜ ๋ชฉํ‘œ๊ฒฝํ—˜

  • React๋ฅผ ์‚ฌ์šฉํ•ด TodoList๋ฅผ ์ง์ ‘ ๊ตฌํ˜„ํ•ฉ๋‹ˆ๋‹ค.
  • styled-component๋ฅผ ์‚ฌ์šฉํ•ด ์Šคํƒ€์ผ์ด ์ ์šฉ๋œ ์ปดํฌ๋„ŒํŠธ๋ฅผ ์ฒ˜์Œ๋ถ€ํ„ฐ ๋งŒ๋“ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • 2500๊ฐœ์˜ ํ•  ์ผ ์ปดํฌ๋„ŒํŠธ๋ฅผ ๋ Œ๋”๋งํ•˜๋ฉฐ ๋ Œ๋”๋ง ์ง€์—ฐ ํ˜„์ƒ์„ ๊ฒช๊ณ  ๋ Œ๋”๋ง ์ตœ์ ํ™”๋ฅผ ํ†ตํ•ด ์ด๋ฅผ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • ์ปดํฌ๋„ŒํŠธ ๊ฐ€์ƒํ™”๋ฅผ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์— ์ ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

1๏ธโƒฃ Step1 ์š”๊ตฌ์‚ฌํ•ญ

์•„์ด์ฝ˜์€ react-icons๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค

MdCheckBoxOutlineBlank,
MdCheckBox,
MdRemoveCircleOutline,
MdAdd

์•„๋ž˜์˜ ๋งํฌ์— ๊ตฌํ˜„๋œ To-do List๋ฅผ ๊ตฌํ˜„ํ•˜์„ธ์š”.

  • styled-components ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•ด style์„ ์ž…ํ˜€์•ผํ•ฉ๋‹ˆ๋‹ค.
  • ๐ŸŒ Link
  • Greedy Logo Image๋Š” /src/asset์— ์กด์žฌํ•˜๋ฉฐ ์•„์ด์ฝ˜์€ /public ํด๋”์— ์กด์žฌํ•ฉ๋‹ˆ๋‹ค.

์š”๊ตฌ ๊ธฐ๋Šฅ์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

  • ์‚ญ์ œ/์ถ”๊ฐ€/์ฒดํฌ ๊ธฐ๋Šฅ์ด ์žˆ์–ด์•ผ ํ•˜๋ฉฐ App.js(jsx)์—์„œ ๊ตฌํ˜„๋ฉ๋‹ˆ๋‹ค.
  • todos ๋ฐฐ์—ด์€ ์ƒํƒœ๋กœ ๊ด€๋ฆฌ๋˜์–ด์•ผํ•˜๋ฉฐ ๊ทธ ๋‚ด๋ถ€ ๊ฐ์ฒด๋Š” ์•„๋ž˜์˜ key๊ฐ’์„ ๊ฐ€์ ธ์•ผํ•ฉ๋‹ˆ๋‹ค.
    {
      id : i,
      text : `ํ•  ์ผ${i}`,
      checked:false,
    }
    

๐ŸŽฉ ์•„๋ž˜์˜ ์ปดํฌ๋„ŒํŠธ๋ฅผ ์ œ์ž‘ํ•˜๊ณ  ๊ธฐ๋Šฅ์„ ์ง€์ผœ์ฃผ์„ธ์š”.

TodoTemplate
ํ™”๋ฉด์„ ๊ฐ€์šด๋ฐ์— ์ •๋ ฌ์‹œ์ผœ์ฃผ๋ฉฐ, ์•ฑ ํƒ€์ดํ‹€(์ผ์ •๊ด€๋ฆฌ)๋ฅผ ๋ณด์—ฌ์คŒ. children์œผ๋กœ ๋‚ด๋ถ€ JSX๋ฅผ Props๋กœ ๋ฐ›์•„์™€ ๋ Œ๋”๋งํ•ฉ๋‹ˆ๋‹ค.
TodoInsert
์ƒˆ๋กœ์šด ํ•ญ๋ชฉ์„ ์ž…๋ ฅํ•˜๊ณ  ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ๋Š” ์ปดํฌ๋„ŒํŠธ. state๋ฅผ ํ†ตํ•ด์„œ ์ธํ’‹์˜ ์ƒํƒœ๋ฅผ ๊ด€๋ฆฌํ•ฉ๋‹ˆ๋‹ค.

TodoListItem

๊ฐ ํ•  ์ผ ํ•ญ๋ชฉ์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ ๋ณด์—ฌ์ฃผ๋Š” ์ปดํฌ๋„ŒํŠธ. Todo ๊ฐ์ฒด๋ฅผ props๋กœ ๋ฐ›์•„์™€ ์ƒํƒœ์— ๋”ฐ๋ผ ๋‹ค๋ฅธ ์Šคํƒ€์ผ์˜ UI๋ฅผ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค.

TodoList

todo๋ฐฐ์—ด์„ props๋กœ ๋ฐ›์•„ ์˜จ ํ›„, ์—ฌ๋Ÿฌ๊ฐœ์˜ TodoListItem ์ปดํฌ๋„ŒํŠธ๋กœ ๋ณ€ํ™˜ํ•œ ํ›„ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค.

2๏ธโƒฃ Step2 ์š”๊ตฌ์‚ฌํ•ญ

  • Step1์˜ ์š”๊ตฌ์‚ฌํ•ญ ๊ตฌํ˜„์„ ์™„๋ฃŒํ–ˆ๋‹ค๋ฉด ์•„๋ž˜์˜ createBulkTodos()ํ•จ์ˆ˜๋ฅผ todos์ƒํƒœ์— ์ดˆ๊ธฐํ™”ํ•˜๋ฉฐ ์„ ์–ธํ•ด์ฃผ์„ธ์š”.
    //App.js
    function createBulkTodos(){
    const array = [];
    for(let i=1;i<2500;i++)
      array.push({
          id : i,
          text : `ํ•  ์ผ${i}`,
          checked:false,
          });
      }
    return array;
    }
    function App() {
    const [todos, setTodos] = useState(createBulkTodos());
    ...some codes...
    }
    2500๊ฐœ์˜ ๋ฐ์ดํ„ฐ๋ฅผ ๋ Œ๋”๋งํ•˜๋ฉด ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์€ ๋Š๋ ค์ง‘๋‹ˆ๋‹ค. ์™œ ๋Š๋ ค์ง€๋Š”์ง€ ์›์ธ์„ ๋ถ„์„ํ•˜๊ณ  ๊ทธ ๊ฒฐ๊ณผ๋ฅผ PR์— ์ ์–ด์ฃผ์„ธ์š”. ReactDevTools-Profiler๋ฅผ ์ด์šฉํ•ด์„œ ์–ด๋–ค ์ปดํฌ๋„ŒํŠธ๊ฐ€ ๋ฆฌ๋ Œ๋”๋ง๋˜๋Š”์ง€ ํ™•์ธํ•˜๊ณ  ์›์ธ์„ ๋ถ„์„ํ•ด ์ปดํฌ๋„ŒํŠธ ๋ Œ๋”๋ง ์ตœ์ ํ™”์™€ ๊ฐ€์ƒํ™”๋ฅผ ์ด๋ค„๋‚ด๋ณด์„ธ์š”.
    • ์ปดํฌ๋„ŒํŠธ ์ตœ์ ํ™”&๊ฐ€์ƒํ™”๋ฅผ ์ ์šฉํ•˜๊ธฐ ์ด์ „์˜ Profiler์˜ ์Šคํฌ๋ฆฐ์ƒท๊ณผ ์ดํ›„์˜ ์Šคํฌ๋ฆฐ์ƒท์„ ์ฐ์–ด ๋น„๊ตํ•ด์ฃผ์„ธ์š”.

โœ… ํ‚ค์›Œ๋“œ

  • React.memo
  • useMemo
  • useCallback
  • useRef
  • react-virtualized(๊ฐ€์ƒํ™” ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ)

๐Ÿง™โ€โ™€๏ธ ์ง„ํ–‰ ๊ฐ€์ด๋“œ

  • ์ง„ํ–‰ ์‹œ๊ฐ„: 4์ผ ๋‚ด์— ์™„๋ฃŒํ•˜๋Š” ๊ฒƒ์„ ๋ชฉํ‘œ๋กœ ํ•ฉ๋‹ˆ๋‹ค.

๐Ÿ”— ์ฐธ๊ณ  ๋ฌธ์„œ

About

๐Ÿ“‹ React TodoList ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ - ์ตœ์ ํ™”

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published