๐Ÿ‘ฉ‍๐Ÿ’ป๊ฐœ๋ฐœ_TIL/TIL

[๋ฆฌ์•กํŠธ]๋ฆฌ์•กํŠธ ๋ผ์šฐํ„ฐ ์ดˆ๊ธฐ ์„ธํŒ…์„ ํ•ด๋ณด์ž!

Daisy.lee 2021. 12. 25. 21:03

1. ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์„ค์น˜

yarn add react-router-dom ๋˜๋Š” npm install react-router-dom

(์ตœ์‹  ๋ฒ„์ „๋ณด๋‹ค ๋‹ค์šด๊ทธ๋ ˆ์ด๋“œ๋œ ๋ฒ„์ „์„ ์‚ฌ์šฉํ•˜๊ณ  ์‹ถ์€ ๊ฒฝ์šฐ: react-router-dom@5(5๋ฒ„์ „)๊ณผ ๊ฐ™์ด ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค.

2. importํ•˜๊ธฐ

3. App ๊ฐ์‹ธ๊ธฐ

import์™€ App ๊ฐ์‹ธ๊ธฐ๋Š” index.js ํŒŒ์ผ์—์„œ ํ•œ ๋ฒˆ์— ํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.


react-router-dom์ด๋ผ๋Š” ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์„ค์น˜ํ•˜๊ณ  ๊ฑฐ์ณ์•ผ ํ•  ๋‹จ๊ณ„๋ฅผ ์ •๋ฆฌํ•˜๊ณ , ๋‚˜์ค‘์— ๋‹ค๋ฅธ ํ”„๋กœ์ ํŠธ์— ์ ์šฉํ•  ๋•Œ ๋”์šฐ ์‰ฝ๊ฒŒ ์ฐพ์„ ์ˆ˜ ์žˆ๋„๋ก ์ผ์Šต๋‹ˆ๋‹ค.๐Ÿ˜Š happy hacking ํ•˜์„ธ์š”!