Replies: 1 comment 7 replies
-
function useAtomWithFunctionScopeValue(v) {
const vAtom = useMemo(() => atom((get) => get(myArrayAtom)[v]), [v]);
return useAtomValue(vAtom);
} |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I checked #2001
Although it is rejected, I still want to discuss a scenario:
Suppose I need such a hook, from its implementation we know it is better rerendered when arr[v] changes, instead of rerender every time the array changes. Since v is provided when using the hook, is there any solution to achieve such an ability?
Inspired by https://ariakit.org/guide/component-stores#computed-values
Beta Was this translation helpful? Give feedback.
All reactions