Recoil icon indicating copy to clipboard operation
Recoil copied to clipboard

Performance best practices?

Open FezVrasta opened this issue 2 years ago • 1 comments

Do you think it would be a good idea to provide a "performance best practices" page in the docs?

A possible example would be:

// Subscribing to atoms can be expensive and lead to unnecessary rerenders
const value = useRecoilValue(myAtom);
const action = useCallback(() => {
  // do something with value
}, [value]);

// Consider using `useRecoilCallback` to only access the atom state when needed instead
const action = useRecoilCallback(({ snapshot }) => async () => {
  const value = await snapshot.getPromise(myAtom);
  // do something with value
}, []);

FezVrasta avatar Jun 17 '22 11:06 FezVrasta

This page already exists, so maybe it would make sense to add here? https://recoiljs.org/docs/basic-tutorial/performance/

Relatedly, I found that page via google. It seems that maybe the docs need updated to include a link to it?

aussio avatar Jul 03 '22 13:07 aussio