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
Now if I update value, I automatically get updated data.
react-async supports something similar
const [value, setValue] = useState();
const { data } = useAsync({ promiseFn: myFetchFn, value, watch: value })
However, when I first did this, I expected watch to follow useEffect's syntax of passing an array of dependencies rather than it watching the primitive value. ex: watch: [value]
It would be great if react-async treated an array being passed in to watch similar to the dependency array in useEffect as it's a little confusing coming from useEffect why passing an array causes an infinite render loop.
The text was updated successfully, but these errors were encountered:
This would be a breaking change, but I can get behind adding special handling for arrays. Feel free to open a PR. For now, you can achieve what you want using watchFn:
useEffect
is a common way to load async data right now in React.useEffect
supports watching specific dependencies.Now if I update
value
, I automatically get updated data.react-async
supports something similarHowever, when I first did this, I expected watch to follow
useEffect
's syntax of passing an array of dependencies rather than it watching the primitive value. ex:watch: [value]
It would be great if
react-async
treated an array being passed in towatch
similar to the dependency array inuseEffect
as it's a little confusing coming fromuseEffect
why passing an array causes an infinite render loop.The text was updated successfully, but these errors were encountered: