usePluginConfig.tsx 437 B

1234567891011121314151617
  1. import { useAsync } from 'react-use';
  2. import { loadPlugin } from '../../utils';
  3. import { CatalogPlugin } from '../types';
  4. export const usePluginConfig = (plugin?: CatalogPlugin) => {
  5. return useAsync(async () => {
  6. if (!plugin) {
  7. return null;
  8. }
  9. if (plugin.isInstalled && !plugin.isDisabled) {
  10. return loadPlugin(plugin.id);
  11. }
  12. return null;
  13. }, [plugin?.id, plugin?.isInstalled, plugin?.isDisabled]);
  14. };