+ {data?.createdAt + ? getTimePassed(new Date(data.createdAt)) + : "1일 전"} +
+{data?.content}
+-
+ {data?.tags?.map((tag) => {
+ return (
+
- + #{tag.name} + + ); + })} +
{data?.likes?.length}
+diff --git a/sona/week5/mission1/.gitignore b/sona/week5/mission1/.gitignore new file mode 100644 index 00000000..83e1c004 --- /dev/null +++ b/sona/week5/mission1/.gitignore @@ -0,0 +1,24 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* +.env +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/sona/week5/mission1/README.md b/sona/week5/mission1/README.md new file mode 100644 index 00000000..40ede56e --- /dev/null +++ b/sona/week5/mission1/README.md @@ -0,0 +1,54 @@ +# React + TypeScript + Vite + +This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. + +Currently, two official plugins are available: + +- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh +- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh + +## Expanding the ESLint configuration + +If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules: + +```js +export default tseslint.config({ + extends: [ + // Remove ...tseslint.configs.recommended and replace with this + ...tseslint.configs.recommendedTypeChecked, + // Alternatively, use this for stricter rules + ...tseslint.configs.strictTypeChecked, + // Optionally, add this for stylistic rules + ...tseslint.configs.stylisticTypeChecked, + ], + languageOptions: { + // other options... + parserOptions: { + project: ['./tsconfig.node.json', './tsconfig.app.json'], + tsconfigRootDir: import.meta.dirname, + }, + }, +}) +``` + +You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules: + +```js +// eslint.config.js +import reactX from 'eslint-plugin-react-x' +import reactDom from 'eslint-plugin-react-dom' + +export default tseslint.config({ + plugins: { + // Add the react-x and react-dom plugins + 'react-x': reactX, + 'react-dom': reactDom, + }, + rules: { + // other rules... + // Enable its recommended typescript rules + ...reactX.configs['recommended-typescript'].rules, + ...reactDom.configs.recommended.rules, + }, +}) +``` diff --git a/sona/week5/mission1/eslint.config.js b/sona/week5/mission1/eslint.config.js new file mode 100644 index 00000000..092408a9 --- /dev/null +++ b/sona/week5/mission1/eslint.config.js @@ -0,0 +1,28 @@ +import js from '@eslint/js' +import globals from 'globals' +import reactHooks from 'eslint-plugin-react-hooks' +import reactRefresh from 'eslint-plugin-react-refresh' +import tseslint from 'typescript-eslint' + +export default tseslint.config( + { ignores: ['dist'] }, + { + extends: [js.configs.recommended, ...tseslint.configs.recommended], + files: ['**/*.{ts,tsx}'], + languageOptions: { + ecmaVersion: 2020, + globals: globals.browser, + }, + plugins: { + 'react-hooks': reactHooks, + 'react-refresh': reactRefresh, + }, + rules: { + ...reactHooks.configs.recommended.rules, + 'react-refresh/only-export-components': [ + 'warn', + { allowConstantExport: true }, + ], + }, + }, +) diff --git a/sona/week5/mission1/index.html b/sona/week5/mission1/index.html new file mode 100644 index 00000000..420ff807 --- /dev/null +++ b/sona/week5/mission1/index.html @@ -0,0 +1,13 @@ + + +
+ + + +navigate(-1)}> + {"<"} +
+
+ navigate(-1)}> +
++ {data?.createdAt + ? getTimePassed(new Date(data.createdAt)) + : "1일 전"} +
+{data?.content}
+{data?.likes?.length}
+로딩 중...
; + if (isError) return에러가 발생했습니다.
; + + const allComments = data?.pages.flatMap((page) => page.data.data) ?? []; + + return ( +댓글
+{comment.author.name}
+ + {isEdit ? ( + + ) : ( +{comment.content}
+ )} ++ {getTimePassed(new Date(item.createdAt))} +
+로딩 중...
; + if (isError || !data) + return에러 발생
; + + return ( + <> + {isModalOpen && ( +{data.data?.email}
+{data.data?.name}
+{data.data?.bio || "프론트 짱"}
+{data.data?.email}
++ 정말 탈퇴하시겠습니까? +
+
+
-