Open cinic opened 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
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:
second request can be resolved after third and u will have not actual list of titles.
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.
https://github.com/fireshipMe/BabyMovieSearcher/blob/a6f6520ebb34d4544a43e9dd82920b9ec7bbd10a/src/App.tsx#L56
Kirill, why not
return props.text && <div>...</div>
orreturn props.text ? <div>...</div> : null
Why u don't use arrow functions and props destructurisation?