Skip to content

Commit

Permalink
chore: renaming isFetching to isLoading
Browse files Browse the repository at this point in the history
  • Loading branch information
elylucas committed Dec 21, 2023
1 parent 4c57799 commit e7caa56
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions packages/experience-builder-sdk/src/hooks/useFetchByBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@ import type { Experience } from '@contentful/experience-builder-core/types';

export const useFetchByBase = (fetchMethod: () => Promise<Experience<EntityStore> | undefined>) => {
const [experience, setExperience] = useState<Experience<EntityStore>>();
const [isFetching, setIsFetching] = useState(false);
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState<Error>();

useEffect(() => {
(async () => {
setIsFetching(true);
setIsLoading(true);
setError(undefined);
try {
const exp = await fetchMethod();
setExperience(exp);
} catch (error) {
setError(error as Error);
} finally {
setIsFetching(false);
setIsLoading(false);
}
})();
}, [fetchMethod]);

return {
error,
experience,
isFetching,
isLoading,
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('useFetchById', () => {

await waitFor(() => {
expect(result.current).toBeDefined();
expect(result.current.isFetching).toBe(true);
expect(result.current.isLoading).toBe(true);
});
});

Expand Down Expand Up @@ -158,7 +158,7 @@ describe('useFetchById', () => {
expect(result.current.error?.message).toBe(
'Failed to fetch experience entities. Required "locale" parameter was not provided'
);
expect(result.current.isFetching).toBe(false);
expect(result.current.isLoading).toBe(false);
});

rerender({ ...initialProps, localeCode });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('useFetchBySlug', () => {

await waitFor(() => {
expect(result.current).toBeDefined();
expect(result.current.isFetching).toBe(true);
expect(result.current.isLoading).toBe(true);
});
});

Expand Down Expand Up @@ -135,7 +135,7 @@ describe('useFetchBySlug', () => {
expect(result.current.error?.message).toBe(
`More than one experience with identifier: ${JSON.stringify({ slug })} was found`
);
expect(result.current.isFetching).toBe(false);
expect(result.current.isLoading).toBe(false);
expect(clientMock.getEntries).toHaveBeenCalledTimes(1);
});

Expand Down Expand Up @@ -193,7 +193,7 @@ describe('useFetchBySlug', () => {
expect(result.current.error?.message).toBe(
'Failed to fetch experience entities. Required "locale" parameter was not provided'
);
expect(result.current.isFetching).toBe(false);
expect(result.current.isLoading).toBe(false);
});

rerender({ ...initialProps, localeCode });
Expand Down

0 comments on commit e7caa56

Please sign in to comment.