Skip to content

Commit

Permalink
Implement useAPIErrorHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmilburn committed Feb 6, 2024
1 parent 5bc1f92 commit 0d15859
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions admin/src/hooks/use-plugin-config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { useEffect } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { useFetchClient, useNotification } from '@strapi/helper-plugin';
import { useAPIErrorHandler, useFetchClient, useNotification } from '@strapi/helper-plugin';

import { ACTION_RESOLVE_CONFIG } from '../constants';
import { pluginId } from '../utils';

const usePluginConfig = () => {
const { formatAPIError } = useAPIErrorHandler();
const dispatch = useDispatch();
const fetchClient = useFetchClient();
const toggleNotification = useNotification();
Expand All @@ -32,10 +33,10 @@ const usePluginConfig = () => {

toggleNotification({
type: 'warning',
message: { id: 'notification.error' },
message: formatAPIError(err),
});
});
}, [isLoading, config, dispatch, fetchClient, toggleNotification]);
}, [isLoading, config, dispatch, fetchClient, toggleNotification, formatAPIError]);

return {
data: config,
Expand Down

0 comments on commit 0d15859

Please sign in to comment.