usePlugins

This commit is contained in:
Jan Prochazka 2020-11-21 17:40:16 +01:00
parent e14165c403
commit 8ab8034060

View File

@ -38,3 +38,15 @@ export default function PluginsProvider({ children }) {
}, [installedPlugins]); }, [installedPlugins]);
return <PluginsContext.Provider value={plugins}>{children}</PluginsContext.Provider>; return <PluginsContext.Provider value={plugins}>{children}</PluginsContext.Provider>;
} }
export function usePlugins() {
const installed = useInstalledPlugins();
const loaded = React.useContext(PluginsContext);
return installed
.map((manifest) => ({
packageName: manifest.name,
manifest,
content: loaded[manifest.name],
}))
.filter((x) => x.content);
}