Recoil
Recoil copied to clipboard
Performance best practices?
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
}, []);
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?