0
Button working only on double click.
Hello guys, I am working on an unsplash application. I fetched the data using unsplash api. I added a total of 3 buttons. One button named 'GO' is working fine but the other 2 buttons named 'HILLS' 'BEACH' are working on double click which I want to work in one click. These two buttons fetch data of hills and beach while the GO button is like a submit button for the search bar. Sorry for the code I don't know how to run a component in solo learn. Please help me. Thanks in advance. https://code.sololearn.com/Wbg6Vs0eT3cm/?ref=app
6 odpowiedzi
+ 1
In your code you are setting the state and using it in the fetchImages() function, as soon as the setSearch is set the component re renders and the fetchImages() has the previous value of search as undefined
Although, There's still some issue,
You can get rid of the go button now
0
i think it's working fine
https://code.sololearn.com/Wym54P9KYvj9/?ref=app
0
Ya the buttons are working on double click but I want those to work on single click.
0
Venkat Ram ok, check now it's working
0
Thanks a lot it's working 🙂
Can you please point my mistake?
Thanks in advance.
Мг. Кнап🌠
0
Thanks a lot!!