diff --git a/src/rtk/app/hooksCommon.ts b/src/rtk/app/hooksCommon.ts index d0d63dc3a..246ba1f46 100644 --- a/src/rtk/app/hooksCommon.ts +++ b/src/rtk/app/hooksCommon.ts @@ -1,6 +1,6 @@ import { AsyncThunkAction } from '@reduxjs/toolkit' import { isEmptyArray, newLogger } from '@subsocial/utils' -import { useEffect, useState } from 'react' +import { useEffect, useMemo, useState } from 'react' import { shallowEqual } from 'react-redux' import useSubsocialEffect from 'src/components/api/useSubsocialEffect' import { @@ -52,6 +52,10 @@ export function useFetchWithoutApi( const [error, setError] = useState() const dispatch = useAppDispatch() + const jsonArgs = useMemo(() => { + return JSON.stringify(args) + }, [args]) + const isEnabled = !!enabled useEffect(() => { if (!isEnabled) return @@ -75,7 +79,7 @@ export function useFetchWithoutApi( return () => { isMounted = false } - }, [dispatch, args, isEnabled]) + }, [dispatch, jsonArgs, isEnabled]) return { loading, diff --git a/src/rtk/features/creators/creatorsListHooks.ts b/src/rtk/features/creators/creatorsListHooks.ts index c3a7d10b3..ce7279549 100644 --- a/src/rtk/features/creators/creatorsListHooks.ts +++ b/src/rtk/features/creators/creatorsListHooks.ts @@ -2,11 +2,12 @@ import { useFetchWithoutApi } from 'src/rtk/app/hooksCommon' import { useAppSelector } from 'src/rtk/app/store' import { fetchCreators, selectCreators } from './creatorsListSlice' +const emptyArgs = {} export function useFetchCreators(config?: { enabled?: boolean }) { const { enabled } = config || {} const data = useAppSelector(state => selectCreators(state)) - const props = useFetchWithoutApi(fetchCreators, {}, { enabled }) + const props = useFetchWithoutApi(fetchCreators, emptyArgs, { enabled }) return { ...props,