Closed11
recoilを試していく

上記の記事が気になったのでrecoilを試してみる。事前にSuspenceの知識が必要そうだったので、下記の記事を読んでおいた
- https://qiita.com/uhyo/items/4a6315bfccf387407631
- https://qiita.com/uhyo/items/6be96c278c71b0ddb39b
- https://ja.reactjs.org/docs/concurrent-mode-suspense.html
読んだけど、わかったようなわかってないような

公式ドキュメントを読み進めていきながら、何かを作っていくことにする
npx create-react-app recoil-sandbox --template typescript

ディレクトリ構成は https://github.com/weknow-network/recoil-patterns を参考にする

非同期のrefreshしたい場合には工夫が必要
- https://github.com/facebookexperimental/Recoil/issues/85
- https://recoiljs.org/docs/guides/asynchronous-data-queries/#query-refresh
- https://github.com/facebookexperimental/Recoil/issues/422
query refresh patternとされている

今回はOpenWeatherでお天気アプリを作っていく
- Current weather data https://openweathermap.org/current

非制御のライブラリは使うの難しそうな気がする
例えばselectorでfetchするとき特定のパラメータをもたせたいとなると、getでatomからもってくる必要が出てくる

エラー処理

selectorでtry..catchしないでもよさそう(リスローしないでバグらせてた)

ブログちゃんと書いた!
このスクラップは2021/02/05にクローズされました
作成者以外のコメントは許可されていません