Ebi-web / react-room

React部屋で作るTodoアプリケーション
react-room-lime.vercel.app
Other
0 stars 0 forks source link

検索機能の追加 #34

Closed kensiiwasaki closed 2 years ago

kensiiwasaki commented 2 years ago

 #25

動作動画

https://user-images.githubusercontent.com/81737432/179433066-a5f3241a-25d6-43b6-8a68-5a9c57465c51.mov

補足

TypeScriptの理解不足ですが、、、、 こちらanyになっているので、型指定できる方法わかる方いましたら教えてください。。。 (stringもしくはtextにしたい) https://github.com/Ebi-web/react-room/blob/82fe9c028e39d984407f0b3a8553eaf9a0d41db8/src/components/TaskList.tsx#L10

vercel[bot] commented 2 years ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
react-room ✅ Ready (Inspect) Visit Preview Jul 22, 2022 at 7:48PM (UTC)
masa5555 commented 2 years ago
  1. isSearchがfalseのときに、フィルタリングされるのはコードとして非直感的なので逆にしました
  2. フィルタリング条件で使っているString.prototype.indexOf()は、先頭でマッチするときに0を返すのでその場合に対応しました
  3. 検索文字列をstringとすると、それがあるかどうかの判定は難しくないので、フラグ変数isSearchはそこまで必要ないかと思いました。(それよりもpropsが一つ増えるほうが複雑性が増すため)
kensiiwasaki commented 2 years ago

@masa5555 ありがとうございます。 だいぶ遠回りしてる感を感じながら開発していたので勉強になりました!