fireshipMe / BabyMovieSearcher

0 stars 1 forks source link

ES6 & destructuring #1

Open cinic opened 4 years ago

cinic commented 4 years ago

https://github.com/fireshipMe/BabyMovieSearcher/blob/a6f6520ebb34d4544a43e9dd82920b9ec7bbd10a/src/App.tsx#L56

Kirill, why not return props.text && <div>...</div> or return props.text ? <div>...</div> : null

Why u don't use arrow functions and props destructurisation?

fireshipMe commented 4 years ago

Hi, thank you for the first in my life issue! You are right, those are way better conditionals, but suddenly I was making these updates to app after few hours of studying, and just messed up with syntax, wrote not return props.text ? ... but something like return({props.text ? ..., so with parentheses.

Will live this open as a sort of milestone

cinic commented 4 years ago

And u handle makeRequest on every input change look on debounce for this ;-) After u input "Tho" into search field u will have a 3 requests to API:

  1. with "T"
  2. with "Th"
  3. with "Tho"

second request can be resolved after third and u will have not actual list of titles.

fireshipMe commented 4 years ago

Extra thanks for debounce. I was looking for ways to call function just 1 time in a given period of time, but all i found were just setTimeout() which worked for me not. I've used Lodash debounce implementation now with just 2 seconds waiting before API call, hopefully it would work nice.