๐ Library(6)
-
[Library] Zustand
๋ฌด์์ ์ฐ๋ ๋ฌผ๊ฑด์ธ๊ณ ? ์ ์ญ์ํ๊ด๋ฆฌ Library ์ ์ญ์ํ๊ด๋ฆฌ๋ ? ๋ฆฌ์กํธ๋ ์ฌ๋ฌ component๋ค์ ์กฐํฉํ์ฌ ํ๋์ HTML์ ๊ตฌ์ฑํ๋๋ฐ, ํ๋์ state๋ฅผ ๋ค๋ฅธ component์ ๊ณต์ ํ๋ ค๋ฉด props ๊ณผ์ ์ ๊ฑฐ์ณ์ผํ๋ค. ์ด ๋ props๋ ์์ component์์ ํ์ component๋ก ๋จ๋ฐฉํฅ์ฑ์ผ๋ก๋ง ์ด๋ํ ์ ์๊ณ , ํ ๋ฒ์ ํ๋์ component๋ง ์ด๋ํ ์ ์๋ค. state๋ component์ ํ ๋น ๋ ๋ฉ๋ชจ๋ฆฌ; ์ฆ ๋ฐ์ดํฐ๋ผ๊ณ ๋ณผ ์ ์๋ค. ์ต์์ component์ State๋ฅผ 3์ค์ค์ฒฉ๋ ํ์ component์ ์ ๋ฌํ๋ ค๋ฉด 3๋ฒ์ Props๋ฅผ ๊ฑฐ์ณ์ผ ํ๊ณ ์ด๊ฒ์ด ๋์ฑ ๋ณต์กํด์ง๋ฉด ๋งค์ฐ ๋นํจ์จ์ ์ธ ๋ฌธ์ ๊ฐ ๋ฐ์ํ๋๋ฐ ์ด๋ฅผ propsdrilling ์ด๋ผ๊ณ ํ๋ค. ์ ์ญ์ํ๊ด๋ฆฌ๋ ์ด๋ฌํ ํ์์..
2024.03.19 -
[Library] react-hook-form
๊ฐ์: 'form'์ ์ฝ๊ฒ ๋ง๋๋๋ฐ ์ ์ฉํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ฌ์ฉ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ค์น npm install react-hook-form zod์ ๊ฒฐํฉํ์ฌ shema์ ์ ์ฅํด๋ ์ ํจ์ฑ ๊ฒ์ฌ๋ฅผ ๋ถ๋ฌ์ Form์ ๋ง๋ค์ด ๋๋๋ง๋ถ์ ๋์ import { useForm } from 'react-hook-form'; import { zodResolver } from '@hookform/resolvers/zod'; import * as z from 'zod'; const schema = z.object({ name: z.string().min(1, { message: 'Required' }), age: z.number().min(10), }); const ..
2024.03.07 -
[Library] Zod
๊ฐ์ TS๋ฅผ ์ํ data schema ๋ฐ ์ ํจ์ฑ ๊ฒ์ฌ ๋ผ์ด๋ธ๋ฌ๋ฆฌ BE์ FE ์ฌ์ด์์ ๋ฐ์ดํฐ๋ฅผ ๊ฒ์ฆํ๊ณ ์ ์ํ๋๋ฐ ์ฌ์ฉ๋๊ธฐ๋ ํจ TS ํ์ ์ ์ฌ์ฉํ์ฌ ๋ฐ์ดํฐ ๊ตฌ์กฐ๋ฅผ ์ ์ํ๊ณ , Zod schema๋ฅผ ํตํด ๋ฐ์ดํฐ ์ ํจ์ฑ ๊ฒ์ฌ ์ ๋ ฅ๊ฐ์ ์ ํจ์ฑ์ ํ์ธํ๊ณ ์๋ฌ ๋ฉ์์ง ์ ๊ณต ์ฌ์ฉ src/validator ๋๋ ํ ๋ฆฌ์ .ts ํ์ผ์์ฑ ๋ผ์ด๋ธ๋ฌ๋ฆฌ import ํ์, ์๋ฌ๋ฉ์์ง ๋ฐ ๋ฐ์ดํฐ ์ ํจ ํ์ ์์ฑimport { z } from "zod"; const passwordRegex = /^(?=.[a-zA-Z])(?=.*\d)(?=.[@$!%?&])[A-Za-z\d@$!%?&]{8,}$/; const phoneRegex = /^010\d{8}$/; export const registerSchema = z.object(..
2024.03.07 -
[Library] [shadcn/ui]
๊ฐ์ ๋งํฌ: ui.shadcn.com ์ปดํฌ๋ํธ ๋ผ์ด๋ธ๋ฌ๋ก ๋คํฌ๋ชจ๋, ์บ๋ฆฐ๋, ์นด๋, ๋ฒํผ ๋ฑ ๋ค์ํ UI๋ค์ ์ ๊ณตํจ ์ค์น(Next.js ๊ธฐ์ค) ์๋ก์ด ํ๋ก์ ํธ ์์ฑ: CNA npx create next-app@latest my-app --typescript --tailwind --eslint CLI ์ ๋ ฅ npx shadcn-ui@latest init components.json ๊ตฌ์ฑ์ ์ํ ๋ช๊ฐ์ง ์ง๋ฌธ๋ค Would you like to use TypeScript (recommended)? no / yes Which style would you like to use? › Default Which color would you like to use as base color? › Slate Where is yo..
2024.03.04 -
[Library]lodash์ ๋ํ์ฌ
์ ์ JS utility library. ์ฝ๋๋ฅผ ๊ฐ๋จํ๊ฒ ๋์์ฃผ๋ ์ฌ๋ฌ function ์ ๊ณต. ์ฌ์ฉ๋ฐฉ๋ฒ https://lodash.com/ ์ ์ ํ์ผ ๋ค์ด๋ก๋ html ํ์ผ head์ script src="loadash.js">
2023.04.27 -
[Library/JQuery]: ํน์ง ๋ฐ ์ฌ์ฉ๋ฐฉ๋ฒ
์ฅ์ : HTML ํ๊ฒฝ์์ JS ์ฝ๋๋ณด๋ค ๋ ๊ฐ๊ฒฐํ๊ณ ํธ๋ฆฌํ๊ฒ ํ๋ก๊ทธ๋๋ฐ์ด ๊ฐ๋ฅ ๊ณต์ ์ฌ์ดํธ: https://jquery.com/ Library ์ฝ์ ์ฌ์ฉ๋ฐฉ๋ฒ script tag์ $('#id').ํจ์() body tag์ tag id="id" ๋ด์ฉ /tag ๋ช๊ฐ์ง ์์ $(selector).text() : selector์ text ๋ฐํ, ๊ฐ๋จํ ๋ด์ฉ ์ถ๋ ฅ์ ์ ์ฉ $(selector).append() : selector์ element ๋ฐํ. ๋ฐ๋ณต๋ฌธ๊ณผ ๊ฒฐํฉํ์ฌ array, list ๋ฑ ์ถ๋ ฅ์ ์ ์ฉ $(selector).empty() : selector ๋ด์ฉ ๋ฆฌ์ $(selector).click() : selector ํด๋ฆญ ์ด๋ฒคํธ ๋ฐ์ธ๋ฉ $(selector).fadeIn() : selector fadeI..
2023.04.20