{"id":15450897,"url":"https://github.com/cane-bt/first-next-app","last_synced_at":"2026-04-13T22:03:32.012Z","repository":{"id":130495068,"uuid":"582660529","full_name":"cane-bt/first-next-app","owner":"cane-bt","description":"React.jsを理解するためのNext.jsアプリ","archived":false,"fork":false,"pushed_at":"2023-02-23T22:49:07.000Z","size":241,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T09:23:32.549Z","etag":null,"topics":["nextjs","react","vercel"],"latest_commit_sha":null,"homepage":"https://first-next-app-gray.vercel.app/","language":"CSS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cane-bt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-27T14:01:23.000Z","updated_at":"2023-02-13T11:54:16.000Z","dependencies_parsed_at":"2023-04-18T12:47:43.320Z","dependency_job_id":null,"html_url":"https://github.com/cane-bt/first-next-app","commit_stats":null,"previous_names":["cane-bt/first-next-app"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cane-bt/first-next-app","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cane-bt%2Ffirst-next-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cane-bt%2Ffirst-next-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cane-bt%2Ffirst-next-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cane-bt%2Ffirst-next-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cane-bt","download_url":"https://codeload.github.com/cane-bt/first-next-app/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cane-bt%2Ffirst-next-app/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31772643,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T20:17:16.280Z","status":"ssl_error","status_checked_at":"2026-04-13T20:17:08.216Z","response_time":93,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nextjs","react","vercel"],"created_at":"2024-10-01T21:20:36.027Z","updated_at":"2026-04-13T22:03:31.997Z","avatar_url":"https://github.com/cane-bt.png","language":"CSS","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--\n[Next.jsと一緒に学ぶReact講座 - YouTube](https://www.youtube.com/playlist?list=PLwM1-TnN_NN6fUhOoZyU4iZiwhLyISopO)\n --\u003e\n\u003c!--\nThis is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).\n --\u003e\n\n# Getting Started\n\n今回は TypeScript を使用しない\n\nFirst, run the development server:\n\n```bash\nnpm run dev\n# or\nyarn dev\n```\n\nOpen [http://localhost:3000](http://localhost:3000) with your browser to see the result.\n\nYou can start editing the page by modifying `pages/index.js`. The page auto-updates as you edit the file.\n\n[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.js`.\n\nThe `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.\n\nThis project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.\n\n## Learn More\n\nTo learn more about Next.js, take a look at the following resources:\n\n- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.\n- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.\n\nYou can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!\n\n## Deploy on Vercel\n\nThe easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template\u0026filter=next.js\u0026utm_source=create-next-app\u0026utm_campaign=create-next-app-readme) from the creators of Next.js.\n\nCheck out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.\n\n### 要約\n\n- データと処理（ロジック）を分けるのがリファクタリングの基本。これを守るだけである程度読みやすくて使いやすいコードになる\n\n#### Chapter5\n\n##### CSS Modules は便利\n\n- クラスの管理が楽、コードが簡潔\n- BEM は大変、コードが長い\n- 解決方法としていかのものもある\n  - CSS in JS、styled-components や Emotion などのライブラリを使用\n  - TailWindCSS のフレームワークなどを使用する\n\n##### 使い方\n\n- `[好きな名前].module.css`\n- クラスのみ使える（id などは使えない）\n- グローバル css は`_app.js`でのみ読み込む（他のファイルで読み込み厳禁）\n\n#### Chapter6\n\n##### Link コンポーネント\n\n- ユーザー体験がより高速に\n  - 逆に a タグを使用すると状態が初期化されてしまう\n\n#### Chapter7\n\n##### component を繰り返し使う方法\n\nmap を使う\n\n##### 繰り返しを使うメリット\n\n- コード量が少なくて済む\n- component を修正するときに 1 箇所を修正するだけで良い\n\n##### HTML Entities\n\n- `\u0026gt;`アンドで始まり、セミコロンで終わるコード\n- jsx ではエスケープしてくれる\n- HTML Entities をただしく表示させるには\n\n##### 文字列中の HTML タグを HTML に変換する\n\n[【React】HTML 文字列を HTML に変換して表示する方法｜ Web エンジニア研究室](https://www.engilaboo.com/react-html-parse/)\n\n#### Chapter8\n\nリファクタリング\n\n##### jsx を使うメリット\n\nVS Code が jsx に関する構文の補完を出してくれる\n\n##### ディレクトリを src にまとめる\n\n- components, pages, styles ディレクトリを移動する（したほうが見やすい、人によって好みあり）\n  - VS Code の場合は自動で import のパスを変更してくれる（してくれないときもあるのでその時は手動で変更する）\n\n#### さらにファイルを component ごとにまとめる\n\n- `Xxx.jsx`と`Xxx.module.css`が同一階層にたくさんあると管理が大変\n  - `Xxx.jsx`と`Xxx.module.css`を`Xxx`というフォルダーを作成しそこに移動する\n  - そのままだと`Caused by: No such file or directory (os error 2)`というエラーが発生する。解決するためには`Xxx.jsx`を`index.jsx`に変更することでエラーが解決する。\n  - `index`という名前は js において非常に重要な名前。 名前を`index`に置き換えることでディレクトリ名を参照したときにまずは`index`を探してくれる。\n    - このエコシステムを使用することでパスが長くなってしまうのを防いでくれる\n\n#### 相対パスから絶対パスに変更する\n\n- 相対パスより絶対パスの方が良さげ\n- 変更方法は `next.js absolute path`で調べる\n  - [next absolute path - Google 検索](https://www.google.com/search?q=next+absolute+path\u0026client=firefox-b-d\u0026sxsrf=AJOqlzVZRBaQVDPrw1h_JVZuV14bEo9tmw%3A1673187289741\u0026ei=2c-6Y6rlLI3m2roPvdOA8A8\u0026oq=next+absopath\u0026gs_lcp=Cgxnd3Mtd2l6LXNlcnAQAxgAMgYIABAHEB4yCAgAEAgQBxAeMggIABAIEAcQHjIICAAQCBAHEB4yCAgAEAgQBxAeMggIABAIEAcQHjIICAAQCBAHEB4yCAgAEAgQBxAeOgcIIxCwAhAnOgcIABCABBANOggIABAHEB4QCkoECEEYAEoECEYYAFAAWKQHYNQOaABwAXgAgAGkAYgBzASSAQMwLjSYAQCgAQHAAQE\u0026sclient=gws-wiz-serp)\n  - [Advanced Features: Absolute Imports and Module Path Aliases | Next.js](https://nextjs.org/docs/advanced-features/module-path-aliases#:~:text=of%20the%20project.-,an%20example%20of%20this%20configuration%3A,-%2F%2F%20tsconfig.json%20or)\n- VS Code の基本設定では自動インポート補完は相対パスで補完されるので、絶対パスにしたい場合わざわざ修正しなければならず手間がかかる。\n\n  - 絶対パスに変更する場合は VS Code の`.vscode/settings.json`に`\"javascript.preferences.importModuleSpecifier\": \"non-relative\"`を追記する\n\n#### Chapter12\n\n##### useCallback, useEffect の第二引数の使い方\n\n第二引数に値を入れることで、値が変更したことを検知して関数を実行して表示などを更新する。cleanupfunction が先行して実行されることに注意\n\n#### Chapter13\n\n##### useEffect を使用して string, Boolean を扱う\n\nHTML タグでの値の変化による表示の制御は`{}`で囲い、三項演算子を使用する(jsx による制限)。\n何も表示させたくない場合は null を代入する\n\n```jsx:example.jsx\nexport default function Home() {\n  return (\n    \u003c\u003e\n      \u003cbutton onClick={handleDisplay}\u003e{isShow ? \"ひひょうじ\" : \"ひょうじ\"}\u003c/button\u003e\n      \u003cbutton onClick={handleDisplay}\u003e{isShow ? \"表示する\" : null }\u003c/button\u003e\n    \u003c/\u003e\n  );\n}\n```\n\n#### Chapter14\n\n##### immutables(不変変数), destructive method(非破壊メソッド)、スプレッド構文\n\nJavaScript は現在破壊的メソッドが推奨されていない。\nそのためスプレッド構文などを用いて対応する。\n\n#### Chapter15\n\n##### Custome Hooks(カスタムフック)の使い方、使い所\n\n###### カスタムフック（ス）とは\n\n\u003e カスタムフックとは、名前が ”use” で始まり、ほかのフックを呼び出せる JavaScript の関数のことです。\n\u003e [独自フックの作成 – React](https://ja.reactjs.org/docs/hooks-custom.html#:~:text=%E3%82%AB%E3%82%B9%E3%82%BF%E3%83%A0%E3%83%95%E3%83%83%E3%82%AF%E3%81%A8%E3%81%AF%E3%80%81%E5%90%8D%E5%89%8D%E3%81%8B%E3%82%99%20%E2%80%9Duse%E2%80%9D%20%E3%81%A6%E3%82%99%E5%A7%8B%E3%81%BE%E3%82%8A%E3%80%81%E3%81%BB%E3%81%8B%E3%81%AE%E3%83%95%E3%83%83%E3%82%AF%E3%82%92%E5%91%BC%E3%81%B2%E3%82%99%E5%87%BA%E3%81%9B%E3%82%8B%20javascript%20%E3%81%AE%E9%96%A2%E6%95%B0%E3%81%AE%E3%81%93%E3%81%A8%E3%81%A6%E3%82%99%E3%81%99%E3%80%82)\n\n###### カスタムフックスのメリット\n\n- コードを共通化できる\n- return 文までの記述が短くなる\n- 関心ごとを分離させることができる\n\n###### カスタムフックスの使い方\n\n[フックの導入 – React](https://ja.reactjs.org/docs/hooks-intro.html)\n\n- カスタムフックスは共通化（コードの再利用）に使える\n- カスタムフックスは`useXxx`という名前で関数を作成する\n  - [独自フックの作成 – React](https://ja.reactjs.org/docs/hooks-custom.html#:~:text=%E3%81%99%E3%82%8B%E3%81%9F%E3%82%81%E3%81%AB%E3%80%81-,%E5%90%8D%E5%89%8D%E3%81%AF%20use%20%E3%81%A6%E3%82%99%E5%A7%8B%E3%82%81%E3%82%8B%E3%81%B8%E3%82%99%E3%81%8D%E3%81%A6%E3%82%99%E3%81%99)\n- `hooks`ディレクトリを作成してそこにコードを記述することができる。ディレクトリ名は`utils`などいろいろあるのでチームの決まりに合わせる\n- フックスを使用する場合のルールがある[フックのルール – React](https://ja.reactjs.org/docs/hooks-rules.html)\n  - フックを呼び出すのはトップレベルのみ\n  - フックを呼び出すのは React の関数内のみ\n    - フックを通常の JavaScript 関数から呼び出さないでください\n- ファイルの拡張子は jsx のほうがわかりやすい（かも）\n- カスタムフックスとコンポーネントの使い分け\n  - コンポーネントとロジックを一緒にしたいのであればコンポーネントとして作成する\n  - コンポーネントとロジックを分けたい（UI は自由度を持たせたい）のであればカスタムフックとして作成する\n\n#### Chapter16\n\n##### State のリフトアップ(状態共通化)\n\n状態共通化といってる\n大きく 2 通り\n\n- ページ間での状態を共通化する方法(Next.js 可、React.js 不可 - [【Next.js で学ぶ React 講座 #16】State のリフトアップでページ間やコンポーネント間で値を共通化しよう！ - YouTube](https://youtu.be/Jhi2X4zkyPI?list=PLwM1-TnN_NN6fUhOoZyU4iZiwhLyISopO\u0026t=627))\n- コンポーネント間での状態を共通化する方法(Next.js 可、React.js 可)\n  - 親からは props, 子で引数に値を分割代入する\n\n#### Chapter17\n\n##### useMemo, useRouter\n\nuseMemo は必要なタイミングで値の評価、再生成させるために使用する。\nパフォーマンスの向上につながる可能性が高い。\n\nuseRouter で使用できるプロパティは以下\n[next/router | Next.js](https://nextjs.org/docs/api-reference/next/router#router-object)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcane-bt%2Ffirst-next-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcane-bt%2Ffirst-next-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcane-bt%2Ffirst-next-app/lists"}