marcopeg-dev / m07-cv-frontend

Frontend for M07 class project
4 stars 3 forks source link

Search bar #36

Closed VernitaJ closed 4 years ago

VernitaJ commented 4 years ago

2 commits. One from Paula and one from Farooq. fixes#18

VernitaJ commented 4 years ago

On the first render, all users should appear, until onChange is fired. At the moment, on first render, the screen just says 'Loading...'

image

paulatorre commented 4 years ago

On the first render, all users should appear, until onChange is fired. At the moment, on first render, the screen just says 'Loading...'

Yeah I know, I put some comments on HomeView where I'm managing the state. Not sure how to solve it because I thought this was enough const [searchResults, setSearchResults] = useState([users]);

image

Deve1980 commented 4 years ago

Hi @paulatorre Try to add setSearchResults(users) to the line 15

paulatorre commented 4 years ago

Hej @Deve1980 :) Do you mean in the UseEffect? (I was playing with use ref and adding some extra lines so now I'm lost with the order I had before) Thanks!

Hi @paulatorre Try to add setSearchResults(users) to the line 15

Deve1980 commented 4 years ago

If you want to view users from first time you loading the page, add this line add setSearchResults(users) to the useEffect. and can change [searchResults,setSearchResults] = useState(users) to useState("")

paulatorre commented 4 years ago

yes, I want that! I didn't understand where to add what you suggested (setSearchResults(users)) because now my line 15 has a different code

Deve1980 commented 4 years ago

in the useEffect that used to FOCUS ON SEARCH INPUT

paulatorre commented 4 years ago

Finally fixed by adding a "users" as a second dependency of the use effect that handles the filter

VernitaJ commented 4 years ago

Finally fixed by adding a "users" as a second dependency of the use effect that handles the filter

Did you mean to close this request? @paulatorre