mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-07-01 10:42:19 +08:00
* fix: context add displayName * fix: observer add displayName * fix: memo component add displayName * fix: forwordRef component add displayName
24 lines
693 B
TypeScript
24 lines
693 B
TypeScript
import { useRequest } from '@nocobase/client';
|
|
import { Spin } from 'antd';
|
|
import React, { createContext, useContext } from 'react';
|
|
|
|
const AvailableActionsContext = createContext([]);
|
|
AvailableActionsContext.displayName = 'AvailableActionsContext';
|
|
|
|
export const AvailableActionsProvider: React.FC = (props) => {
|
|
const { data, loading } = useRequest<{
|
|
data: any[];
|
|
}>({
|
|
resource: 'availableActions',
|
|
action: 'list',
|
|
});
|
|
if (loading) {
|
|
return <Spin />;
|
|
}
|
|
return <AvailableActionsContext.Provider value={data?.data}>{props.children}</AvailableActionsContext.Provider>;
|
|
};
|
|
|
|
export const useAvailableActions = () => {
|
|
return useContext(AvailableActionsContext);
|
|
};
|