-
Notifications
You must be signed in to change notification settings - Fork 90
Open
Labels
enhancementEnhancement to existing featureEnhancement to existing feature
Description
useEffect is a common way to load async data right now in React. useEffect supports watching specific dependencies.
const [value, setValue] = useState();
useEffect(() => {
setData(myFetchFn({ value });
return cancel;
}, [value]);
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.
bravokiloecho, ReeseJones, christopher-francisco, behzad-a, Ciccio99 and 1 more
Metadata
Metadata
Assignees
Labels
enhancementEnhancement to existing featureEnhancement to existing feature