You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem is when I click ( first click ) it logs an error' because userLocationisundefined while the useSWR is fetching the data. The button code is synchronous and the useSWR is asynchronous, how to wait foruserLocationto be available to run theif` code?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have a
Button
component where I get data from my backend API using useSWR.This is my button:
The problem is when I click ( first click ) it logs an
error' because
userLocationis
undefinedwhile the useSWR is fetching the data. The button code is synchronous and the useSWR is asynchronous, how to wait for
userLocationto be available to run the
if` code?Beta Was this translation helpful? Give feedback.
All reactions