๐ React(4)
-
ํ์ ์ปดํฌ๋ํธ์ boolean(์ฐธ/๊ฑฐ์ง) props ๋ณ์ ์ ๋ฌ
React์์ ํ์ ์ปดํฌ๋ํธ๋ก props ์ ๋ฌ ์, ํน์ ์์์๋ง ์ ๋ฌํ๊ธฐ ์ํ๋ ๋ณ์๊ฐ ์กด์ฌํ๋ค. ์๋ ์์๋ก ๊ฐ๋ก์ค์ ๊ตฌ์ฑํ๋ Row ์ปดํฌ๋ํธ์ ์ฒซ๋ฒ์งธ ์ค์๋ง isLargeRow ๋ณ์๋ฅผ ์ ๋ฌํด ๋ค๋ฅธ ์์๋ณด๋ค ํฌ๊ฒ ํ๋ฉด์ ํํํ๊ณ ์ถ๋ค๋ฉด ํ์ ์ปดํฌ๋ํธ์์ isLargeRow ๋ณ์์ default๊ฐ์ false๋ก ์ง์ ํ ๋ค์ ์ํ๋ ํน์ ์ปดํฌ๋ํธ ์์์๋ง isLargeRow ๋ณ์๋ฅผ ์ ๋ฌํด์ฃผ๋ฉด๋๋ค. ํ์ ์ปดํฌ๋ํธ function Row({ data, isLargeRow = false }) { return( {data.name} ); } export default Row; ์์ ์ปดํฌ๋ํธ๋ก๋ถํฐ data์ isLargeRow์ด๋ผ๋ boolean๊ฐ์ ์ ๋ฌ๋ฐ๋ Row ์ปดํฌ๋ํธ๊ฐ ์กด์ฌํ๋ค. isLargeRow ๋ณ์๋ฅผ..
2021.11.27 -
ํจ์ ์ ๋ฌ ๋ ๋ ์๋ฌ ๋ฌธ์ & ๋ฆฌ์กํธ className ์์ฑ๋ฒ ์ ๋ฆฌ
1. ๋ฒํผ ํด๋ฆญ ์ useState๋ฅผ ํ์ฉํด type์ ๋ณ์ ๊ฐ์ ๋ณ๊ฒฝํด์ฃผ๊ณ ์ถ์ ๋ ์ฝ๋์ ์ค๋ณต๋๋ ๋ถ๋ถ์ ํจ์๋ก ์์ฑํด ์ ๋ฌํด ์ฃผ๋ คํ๋๋ฐ ๋ฌดํ ๋ฐ๋ณต์ด ๋์๊ฐ๋ค. const [type, setType] = useState(''); const handleSortChange = (type) => { setType(type); }; ์ด๋ ๋ฒํผ์ ํด๋ฆญํ์ ๋ ํจ์๋ฅผ ์ ๋ฌํ๋ฉด ๋ฐ์ํ๋ ์๋ฌ๋ก button ์ ํจ์๊ฐ ์คํ๋ ๋ state๋ฅผ ๋ณํํ๋ ์ฝ๋์ด๊ธฐ ๋๋ฌธ์ ๊ณ์ ๋ ๋๋๋ ์๋ฌ๊ฐ ๋ฐ์ํ๋ค. state ๋ณํ์ํฌ ๋ ์๋ ๋ฐฉ๋ฒ์ผ๋ก ์์ฑ ( ) => arrow function์ผ๋ก ํจ์๋ฅผ ์ ๋ฌํด์ฃผ๊ฑฐ๋ ( ) => ๋ฐ๋ก setType() ์ฝ๋๋ฅผ ์์ฑํด ๋ณ์๋ฅผ ์ ๋ฐ์ดํธ ํ๊ฑฐ๋ ๋ ์์์ id ๊ฐ์ ์ง์ ํด์ฃผ๊ณ ์ด๋ฒคํธ ํธ..
2021.11.15 -
[๋ฆฌ์กํธ] ๋งํฌ๋ค์ด ์๋ํฐ 'react-md-editor' ์ค์น ๋ฐ ์ ์ฉ ๋ฐฉ๋ฒ (feat. front)
Summary 1. React ๋งํฌ๋ค์ด ์๋ํฐ ์ค์น yarn add @uiw/react-md-editor 2. Editor ์์ฑ ์ปดํฌ๋ํธ import MDEditor from "@uiw/react-md-editor"; const Editor = (props) => { return ( ) } export default Editor; 3. ๋งํฌ๋ค์ด ๋ทฐ ์ปดํฌ๋ํธ import MDEditor from "@uiw/react-md-editor"; const NoticeView = (props) => { return ( ) } export default NoticeView; Result - ์๋ํฐ ์์ฑ ํ๋ฉด - ๋งํฌ๋ค์ด ์ ์ฉ๋ ๋ทฐ ํ๋ฉด ๐ ๊ธฐ์ธ๊ธฐ, ๊ตต๊ธฐ, ์ด๋ฏธ์ง ๋ฑ ์ ์ฉ ์ฌํญ ์ ์ ๋์ ํ์ธ โ๏ธ CODE ์ค๋ช 'r..
2021.09.29 -
๐react-map-gl, Mapbox๋ฅผ ํ์ฉํ ์ง๋๐บ ํ๋ก์ ํธ ์์ฑ - React ํ๋ก ํธ ํธ๐
| 1. React ์ค์น ํ๋ก ํธ์ค๋ ํด๋๋ก ์ด๋ํด ํ์ฌ ํด๋ ๋ด๋ถ(.)์ react๋ฅผ ์ค์นํ๋ค. cd frontend npx create-react-app . | 2. ํฐํธ ์ ํ fonts.google.com ๋ฆฌ์กํธ ์ค์น๊ฐ ์งํ๋๋ ๋์ ๊ตฌ๊ธ ํฐํธ.com์ ์ ์ํ์ฌ ํ๋ก์ ํธ์ ์ฌ์ฉ๋ ํฐํธ๋ฅผ ๊ณจ๋ผ ํด๋น ์ฝ๋๋ฅผ ๋ณต์ฌํ๋ค. [ ๋ณต์ฌํ ์ฝ๋ ] // link ์ฝ๋ // css ์ฝ๋ font-family: 'Playfair Display', serif; ํด๋น ์ฝ๋๋ฅผ ํ๋ก ํธ์ publicํด๋ > index.html ํ์ผ ๋ด๋ถ์ ๋ถ์ฌ์ฃผ๋ฉด ํ๋ก์ ํธ ์ ๊ธ๊ผด ์ง์ ์ด ์๋ฃ๋๋ค. index.html์ ์์ฑํ css ์คํ์ผ ์ฝ๋๊ฐ 2~3์ค๋ก ์งง๊ธฐ ๋๋ฌธ์ ๋ณ๋์ css ํ์ผ์ ์์ฑํ์ง ์๊ณ html ๋ฌธ์ ๋ด๋ถ์ style ์ฝ๋..
2021.07.23