Posts
Q&A
tailwind.config.ts ํ์ผ ์ค์น๊ฐ ์๋๋ ๋ฌธ์
tailwindcss@3.4.17์ Next.js@14 ์ ์ ์ฉํ ๋ ,Next.js ์ ํ์ ์คํฌ๋ฆฝ ์ ์ฉ ํ๊ฒฝ์ธ๊ฐ ๊ทธ๋ฅ JS ํ๊ฒฝ์ธ๊ฐ์ ๋ฐ๋ผ tailwind.config.js ์ postcss.config.js ํ์ผ ์ฝ๋๊ฐ ๋ค๋ฆ ๋๋ค. tailwindcss ๊ณต์ ๋ฌธ์ ์ฌ์ดํธ์์๋ Next.js ์ react-js ํ๊ฒฝ์์ ์ค์นํ๋ ๋ฐฉ๋ฒ(install Tailwind CSS with Next.js)์ด๋ ๊ทธ๊ฑธ ์ฐธ๊ณ ํ์๊ณ ์.Next.js ์ react-ts ํ๊ฒฝ์์๋ ๋ค์๊ณผ ๊ฐ์ ๋ฐฉ๋ฒ์ผ๋ก ์ค์นํฉ๋๋ค.npm install -D tailwindcss@3 postcss autoprefixernpx npx tailwindcss init -ptailwind.config.ts ํ์ผ ๋ด์ฉimport type { Config } from "tailwindcss"; const config: Config = { content: [ "./pages/**/*.{js,ts,jsx,tsx,mdx}", "./components/**/*.{js,ts,jsx,tsx,mdx}", "./app/**/*.{js,ts,jsx,tsx,mdx}", ], theme: { extend: { colors: { background: "var(--background)", foreground: "var(--foreground)", }, }, }, plugins: [], }; export default config;postcss.config.mjs/** @type {import('postcss-load-config').Config} */ const config = { plugins: { tailwindcss: {}, }, }; export default config;globals.css@tailwind base; @tailwind components; @tailwind utilities; ๐ ๊ทธ๋ฐ๋ฐ ๋ง์ผ nextjs ์คํ์์ ๋ฌธ์ ๊ฐ ์๋๋ผ vscode ์์ lint ์๋ฌ๋ผ๋ฉด. Tailwind intelliSense ์ PostCSS ํ๋ฌ๊ทธ์ธ ์ค์น๋์ด ์๋์ง ํ์ธํ์๊ณ ์. ์๋๋ฉด settings.json ํ์ผ์ ๋ค์๊ณผ ๊ฐ์ ์ต์ ์ ์ฃผ์ด css ํ์ผ์ tailwindcss ํ์ผ๋ก ์ฐ๊ฒฐํด์ผ ํฉ๋๋ค. "file.associations": { "css" : "tailwindcss" },
- 0
- 3
- 272
Q&A
(ToDoList ์ค์ต) ! ์ฐ์ฐ์์ ๋ํด
์ผํญ์ฐ์ฐ์๋ฅผ ๋ณด๋ฉด clickedId ๊ฐ ์ฐธ์ผ ๋, ๊ธฐ์กด aTodo ๊ฐ์ฒด๋ฅผ ๊ทธ๋ฅ ๋ฆฌํดํ๊ณ ๊ฑฐ์ง์ผ ๋ ๊ธฐ์กด aTodo ๊ฐ์ฒด์์ todoDone ์ ๊ฐ์ ! ์ ์ด์ฉํด์ boolean ๊ฐ์ ๋ฐ๋๋ก ์ค์ ํ์ฌ ์๋ก์ด aTodo ๊ฐ์ฒด๋ฅผ ๋ฐํํ๋๋ก ํ๊ณ ์์ต๋๋ค. !true -> false , !false -> true
- 0
- 1
- 66
Q&A
tailwindcss๋ฅผ vite์์ ์ด์ฉํ๋ ๋ฐฉ์์ด ๋ฐ๋๊ฒ ๊ฐ์ต๋๋ค.
tailwindcss v4.0 ์ด ๋๋ฉด์ vite์์ ์ฌ์ฉ ๋ฐฉ์์ด ๋ฐ๋๊ฒ์ผ๋ก ๋ณด์ ๋๋ค.์ด์ tailwindcss v3.x ๋ฅผ ์ค์นํ์ฌ ์ฌ์ฉํ๋ ค๋ฉด ๋ค์๊ณผ ๊ฐ์ด ํ์๋ฉด ๋ฉ๋๋ค.# 1. vite๋ก ๋ฆฌ์กํธ ํ๋ก์ ํธ๋ฅผ ์์ฑํฉ๋๋ค. npx create-vite@latest my-project --template react cd my-project npm install # 2. Tailwind CSS v3.x๋ฅผ ์ค์นํฉ๋๋ค. npm i -D tailwindcss@3 postcss autoprefixer npm tailwindcss init -ptailwind.config.js ํ์ผ ์ค์ /** @type {import('tailwindcss').Config} */ export default { content: [ "./index.html", "./src/**/*.{js,ts,jsx,tsx}", ], theme: { extend: {}, }, plugins: [], }./src/index.css ํ์ผ ์์ @tailwind base; @tailwind components; @tailwind utilities;
- 0
- 2
- 691
Q&A
๋นจ๊ฐ ๋ฐ์ค ์ง๋ฌธ์ด์..
props ์ ๋นจ๊ฐ์ค์ ํด๋น ํ๋ผ๋ฏธํฐ๋ฅผ ์ปดํฌ๋ํธ ์์์ ์ฌ์ฉํ์ง ์๊ณ ์๊ธฐ ๋๋ฌธ์ ๋์ค๋ eslint ์๋ฌํ์์ ๋๋ค. ์ปดํฌ๋ํธ ๋ด์์ ์ฌ์ฉํ์ง ์์ผ๋ฉด props ๋ฅผ ์ ๊ฑฐํ์๊ฑฐ๋.๋ค์ ๊ฐ์์์ ํด๋น props๋ฅผ ํธ์ถํ๋ ๋ด์ฉ์ด ์์ผ๋ฉด ๋นจ๊ฐ์ค์ ์์ฐํ ์ง์์ง ๊ฒ๋๋ค. ํน์ props๋ฅผ ์ฌ์ฉํด๋ props ์ ๋นจ๊ฐ์ค์ด ๋์ค๋ฉด eslin.config.js ํ์ผ ๋๋ eslintrc ํ์ผ rules ๋ถ๋ถ์ "react/prop-types": "off" ์ต์ ์ ์ถ๊ฐํด ์ฃผ์ธ์. PS: JSX ๋ฌธ๋ฒ์์๋ class ์์ฑ์ className ์ด๋ผ๊ณ ํ๊ธฐํ๋ ๊ฒ ๋ง์ต๋๋ค.์ด์ ๋ ์๋ฐ์คํฌ๋ฆฝํธ์ class ํค์๋๋ ์์ฝ์ด๋ผ์ class ์์ฑ์ผ๋ก ์ฌ์ฉํ ์ ์์ด์.
- 0
- 2
- 128
Q&A
vite๋ฅผ ํตํด ํ๋ก์ ํธ ์์ฑ ์ React Router ๋ ๋ฌด์์ผ๊น์?
๋์ค์ react-router, react-router-dom ํจํค์ง ์ค์นํ ๋ ๋ฐ๋ก ์ค์นํ์ง ์์๋ ๋๋ ๊ฒฝ์ฐ์ ๋๋ค.๋ฆฌ์กํธ ๋ผ์ฐํ , ํ์ด์ง ๋ผ์ฐํ ๋ฐฐ์ฐ์ค ๋ ์์ค ๊ฒ๋๋ค.
- 0
- 3
- 638
Q&A
jsx ์ค์ต ๊ด๋ จ ์ค๋ฅ npm start๋ฅผ ํด๋ ๊ฐ์ฌ ํ๋ฉด์ฒ๋ผ ์๋ ์.
npm start ์คํํ๋ ค๋ ํด๋ ๋ด์ package.json ์ ์ฝ์ ์ ์๋ค๋ ์ค๋ฅ์ ๋๋ค.npm install ๋ก ๋ ธ๋ ๋ชจ๋ ํจํค์ง๋ฅผ ์ค์นํ์ง ์์๊ฑฐ๋, package.json ํ์ผ์ด ์๋ ๊ฒฝ๋ก์์ ํ๋ก๊ทธ๋จ์ ์คํํ๋ ค๊ณ ํด์ ๊ทธ๋ฐ ๊ฒ์ผ๋ก ๋ณด์ ๋๋ค.
- 0
- 3
- 420
Q&A
npx create-react-app my-app ๋ช ๋ น์ด ๋ฐ์์์
vite ๋น๋ ๋๊ตฌ๋ฅผ ์ด์ฉํด ๋ณด์ธ์.# ๋ฆฌ์กํธ ํ๋ก์ ํธ ์์ฑ npm create vite@latest my-react-app -- --template react # ํด๋น ํ๋ก์ ํธ ํด๋๋ก ์ด๋ cd my-react-app # ๊ด๋ จ ํจํค์ง ์ค์นํ๊ธฐ npm install # ๋ฆฌ์กํธ ํ๋ก์ ํธ ์คํ npm run dev
- 1
- 3
- 364
Q&A
create-react-app my app ์คํ ์ ์๋ฌ
react@19.0.0 ๊ฐ @testing-library/react@13.4.0 ์ ํธํ์ฑ ์ถฉ๋ํ๋ ์ด์๊ฐ ์์ต๋๋ค. ์ด ์ค๋ฅ๊ฐ ์์ ๋๊ธฐ ์ ๊น์ง๋ ์๋ ๊ฒ ๊ฐ์ต๋๋ค. (create-react-app ์ง์ ์ค๋จ์ด๋ผ..)๋ค๋ฅธ ๋์์ผ๋ก yarn ์ผ๋ก ์ค์น ๋ฐฉ๋ฒ๊ณผ, vite ๋น๋ ๋๊ตฌ๋ก ์ค์นํ๋ ๋ฐฉ๋ฒ์ ์ฌ์ฉํ์ธ์.npm i -g yarn yarn create react-app cd yarn startnpx create-vite@latest --template react cd npm install npm run dev
- 0
- 2
- 298
Q&A
Failed to load module script ์๋ฌ๊ฐ ๋น๋๋ค
ํน์ jsx ๋ฌธ๋ฒ์ด ๋ค์ด๊ฐ ์ปดํฌ๋ํธ ํ์ผ์ ํ์ฅ์๊ฐ .js ์ธ๊ฐ์?๊ทธ๋ ๋ค๋ฉด .jsx๋ก ๋ณ๊ฒฝํด ๋ณด์ธ์. vite ๊ฐ๋ฐ ํ๊ฒฝ์์๋ jsx ๋ฅผ ๋ฐํํ๋ ์ฝ๋ ํ์ผ์ ๋ฐ๋์ ํ์ฅ์๊ฐ jsx ์ด๊ฑฐ๋ ํ์ ์คํฌ๋ฆฝํธ ์์๋ tsx ๋ก ๋์ด ์์ด์ผ ํฉ๋๋ค.
- 0
- 4
- 295
Q&A
npx create-react-app mall ์๋ฌ๊ฐ ๋ฉ๋๋ค
React ๊ฐ 19๋ฒ์ ์ด ๋๋ฉด์ npx create-react-app ์ผ๋ก ํ๋ก์ ํธ ์์ฑ ์ ์ค๋ฅ๊ฐ ๋ฐ์ํ๊ณ ์๋ค์.CRA ๊นํ๋ธ ์ฌ์ดํธ์์๋ ํด๋น ์ด์์ ๋ฐ๋ฅธ ์ง๋ฌธ์ด ๋ง์ต๋๋ค.์ด๊ฒ์ ๋ํ ํด๊ฒฐ๋ฐฉ๋ฒ์ yarn ์ผ๋ก create-react-app ์ ์ค์นํ๊ฑฐ๋ vite ๋ฅผ ์ฌ์ฉํ์ฌ ์ค์นํ๋ ๊ฒ์ ๊ถ์ฅํ๊ณ ์์ต๋๋ค.npm install --global yarn yarn create react-app my-project-app cd my-project-app yarn startnpx create-vite@latest my-project-app --template react cd my-project-app npm install npm run start
- 1
- 3
- 307