Skip to content

Commit ccd3258

Browse files
authored
Merge pull request #8914 from smeng9/master
Expose setNotifications methods in notification contexts
2 parents ff2133b + 3be509e commit ccd3258

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

packages/ra-core/src/notification/NotificationContext.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createContext } from 'react';
1+
import { createContext, Dispatch, SetStateAction } from 'react';
22

33
import { NotificationPayload } from './types';
44

@@ -7,6 +7,7 @@ export type NotificationContextType = {
77
addNotification: (notification: NotificationPayload) => void;
88
takeNotification: () => NotificationPayload | void;
99
resetNotifications: () => void;
10+
setNotifications: Dispatch<SetStateAction<NotificationPayload[]>>;
1011
};
1112

1213
/**
@@ -41,4 +42,5 @@ export const NotificationContext = createContext<NotificationContextType>({
4142
addNotification: () => {},
4243
takeNotification: () => {},
4344
resetNotifications: () => {},
45+
setNotifications: () => {},
4446
});

packages/ra-core/src/notification/NotificationContextProvider.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export const NotificationContextProvider = ({ children }) => {
3030
addNotification,
3131
takeNotification,
3232
resetNotifications,
33+
setNotifications,
3334
}),
3435
[notifications] // eslint-disable-line react-hooks/exhaustive-deps
3536
);

0 commit comments

Comments
 (0)