Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ビートルズデータの読み込み、表示を実装 #3

Closed
ryo-i opened this issue Jan 19, 2022 · 38 comments
Closed

ビートルズデータの読み込み、表示を実装 #3

ryo-i opened this issue Jan 19, 2022 · 38 comments

Comments

@ryo-i
Copy link
Owner

ryo-i commented Jan 19, 2022

・スプシのデータをGoogle Sheets APIでJSON化
・FirebaseのRealtime Databaseにimport
・Realtime Databaseをfetch apiで読み込む
・ページ上に表示する
・その後の処理を検討…

@ryo-i
Copy link
Owner Author

ryo-i commented Jan 19, 2022

@ryo-i
Copy link
Owner Author

ryo-i commented Jan 19, 2022

スプシ→jsonファイル→Realtime Database
配列が全部番号のキー名の連想配列になってる

スクリーンショット 2022-01-20 6 18 25
スクリーンショット 2022-01-20 6 18 34

@ryo-i
Copy link
Owner Author

ryo-i commented Jan 19, 2022

Realtime Databaseのデータをエクスポートしてみたが、元のデータと同じ配列形式だった

DL直後
スクリーンショット 2022-01-20 6 25 06

整形後
スクリーンショット 2022-01-20 6 26 47

連想配列形式になっていればキー名を検索置換したかった

@ryo-i
Copy link
Owner Author

ryo-i commented Jan 19, 2022

fetchで読み込んだデータをconsoleで読み込み
配列形式になっているな
スクリーンショット 2022-01-20 7 05 38

@ryo-i
Copy link
Owner Author

ryo-i commented Feb 7, 2022

#1 でスプシのデータを作り込んだので、それを読み込んだ

スプシのJSON APIのデータを取得
スクリーンショット 2022-02-08 6 32 07

Firebaseにimport
スクリーンショット 2022-02-08 6 26 29

Reactからfetch apiで読み込みconsoleに表示
スクリーンショット 2022-02-08 6 30 09

@ryo-i
Copy link
Owner Author

ryo-i commented Feb 7, 2022

さて、ここから2つの方向性がある。
・firebase側でフィルタを掛けたデータをブラウザ側で読み込むか
・データ全体をブラウザ側で読み込んだあとにReactのみでフィルタリングするか

または上記2つの良いとこ取りのハイブリッド型にするか

@ryo-i
Copy link
Owner Author

ryo-i commented Feb 9, 2022

ひとまず曲名、作品名、発売日のみ抜粋表示に成功ー
スクリーンショット 2022-02-10 7 20 10

@ryo-i
Copy link
Owner Author

ryo-i commented Feb 11, 2022

レイアウトを手直しした
スクリーンショット 2022-02-11 18 50 29

ryo-i added a commit that referenced this issue Feb 11, 2022
ryo-i added a commit that referenced this issue Feb 12, 2022
@ryo-i
Copy link
Owner Author

ryo-i commented Feb 12, 2022

Firebase試行錯誤記録

他にもいろいろ調べたり試したが主要なものしか覚えていない、、

@ryo-i
Copy link
Owner Author

ryo-i commented Feb 14, 2022

Web APIのセオリーとして
・通信回数の最適化
・通信量の最適化
では通信回数の方が効果が大きいため、データ量が多くてもなるべく通信回数が少ない方法を取りたい

参考
https://jp.quora.com/Webプログラミングでは通信量を減らすためにAPIへのリク?ch=2&oid=78106424&srid=NZThn&target_type=question
https://zenn.dev/nakaryo/articles/87b15866d67efe

なお、graphQLは1回の通信で必要な情報だけが返ってくる
https://qiita.com/NagaokaKenichi/items/a4991eee26e2f988c6ec

@ryo-i
Copy link
Owner Author

ryo-i commented Feb 15, 2022

ビートルズデータはapiフォルダにすべきとわかったので移動
https://maku.blog/p/qcp2coz/
https://nextjs-ja-translation-docs.vercel.app/docs/api-routes/introduction

ryo-i added a commit that referenced this issue Feb 15, 2022
@ryo-i
Copy link
Owner Author

ryo-i commented Feb 15, 2022

@ryo-i
Copy link
Owner Author

ryo-i commented Sep 4, 2022

コンポーネントにスタイルを分割するとリロード時に効かない。
class名が一致しないようだ。こちらを参考に対策
https://takumihiguchi.portfolio.branchwith.jp/blog/362r6yyncv7
https://github.com/vercel/next.js/blob/deprecated-main/examples/with-styled-components/pages/_document.js

スタイルは聞くようになったがコンソールエラーは消えない
babel-plugin-styled-componentsも入れてみたが変わらない
https://zenn.dev/nbr41to/articles/c0c691653e3d55
https://www.npmjs.com/package/babel-plugin-styled-components

しかしこの事象はデプロイ環境では起こらないようで、ローカル環境だけの事象かも?

@ryo-i
Copy link
Owner Author

ryo-i commented Sep 4, 2022

style設定に三項演算子を使っているせいとあったので、なくして見たが結果はかわらず
styled-components/babel-plugin-styled-components#333

メッセージにあったページを見ると、フックを使うとよさそう?
https://nextjs.org/docs/messages/react-hydration-error

@ryo-i
Copy link
Owner Author

ryo-i commented Sep 4, 2022

こちらの記事を参考に、CSSのclass名設定などの分岐処理が終わったあとにStyled-Componentsのレンダリングを実行するようにしたら解決した!!
https://zenn.dev/takewell/articles/5ee9530eedbeb82e4de7

ryo-i added a commit that referenced this issue Sep 5, 2022
ryo-i added a commit that referenced this issue Sep 6, 2022
ryo-i added a commit that referenced this issue Sep 6, 2022
ryo-i added a commit that referenced this issue Sep 8, 2022
ryo-i added a commit that referenced this issue Sep 11, 2022
ryo-i added a commit that referenced this issue Sep 12, 2022
@ryo-i
Copy link
Owner Author

ryo-i commented Sep 13, 2022

一通り完成したのでクローズ。
残りは楽曲解説を追加していく。

@ryo-i ryo-i closed this as completed Sep 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant