react js useState array is empty in first time click in the console log react js useState array is empty in first time click in the console log
Please check my below code. I try to check the console log value, but in the first button click, the array is empty. After the second click the array will be loaded correctly.
Please check this:
The above sample can be found on Google. I console log the value as below
Why is the array empty in the first click? Another question is, I need to print the value in the first click. How can I do it? Do you know any alternative method?
from Stackoverflow
Comments
Post a Comment