@calimero-network/mero-react 2.6.0 → 2.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -2107,39 +2107,42 @@ function useMemberMetadata(groupId, identity) {
2107
2107
  const [metadata, setMetadata] = react.useState(null);
2108
2108
  const [loading, setLoading] = react.useState(false);
2109
2109
  const [error, setError] = react.useState(null);
2110
- const mountedRef = useMountedRef();
2111
- const refetch = react.useCallback(async () => {
2112
- if (!mero || !groupId || !identity) {
2113
- if (mountedRef.current) {
2114
- setMetadata(null);
2115
- setError(null);
2116
- setLoading(false);
2117
- }
2118
- return;
2119
- }
2120
- if (mountedRef.current) {
2121
- setLoading(true);
2122
- setError(null);
2123
- }
2124
- try {
2125
- const result = await mero.admin.getMemberMetadata(groupId, identity);
2126
- if (mountedRef.current) {
2127
- setMetadata(result);
2110
+ const run = react.useCallback(
2111
+ async (signal) => {
2112
+ if (!mero || !groupId || !identity) {
2113
+ if (!signal.aborted) {
2114
+ setMetadata(null);
2115
+ setError(null);
2116
+ setLoading(false);
2117
+ }
2118
+ return;
2128
2119
  }
2129
- } catch (err) {
2130
- const errorValue = toError(err);
2131
- if (mountedRef.current) {
2132
- setError(errorValue);
2120
+ if (!signal.aborted) {
2121
+ setLoading(true);
2122
+ setError(null);
2133
2123
  }
2134
- } finally {
2135
- if (mountedRef.current) {
2136
- setLoading(false);
2124
+ try {
2125
+ const result = await mero.admin.getMemberMetadata(groupId, identity);
2126
+ if (!signal.aborted) setMetadata(result);
2127
+ } catch (err) {
2128
+ if (!signal.aborted) setError(toError(err));
2129
+ } finally {
2130
+ if (!signal.aborted) setLoading(false);
2137
2131
  }
2138
- }
2139
- }, [groupId, identity, mero, mountedRef]);
2132
+ },
2133
+ [mero, groupId, identity]
2134
+ );
2140
2135
  react.useEffect(() => {
2141
- void refetch();
2142
- }, [refetch]);
2136
+ const signal = { aborted: false };
2137
+ void run(signal);
2138
+ return () => {
2139
+ signal.aborted = true;
2140
+ };
2141
+ }, [run]);
2142
+ const refetch = react.useCallback(async () => {
2143
+ const signal = { aborted: false };
2144
+ await run(signal);
2145
+ }, [run]);
2143
2146
  return { metadata, loading, error, refetch };
2144
2147
  }
2145
2148
  function useRegisterGroupSigningKey() {