Skip to content

Commit e61cd35

Browse files
authored
Merge pull request #6713 from danielhusar/master
Fix runtime error when type is not supplied to useNotify
2 parents 85406f6 + 1da6fac commit e61cd35

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

packages/ra-core/src/sideEffect/useNotify.ts

+11-7
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,22 @@ const useNotify = () => {
3535
autoHideDuration?: number,
3636
multiLine?: boolean
3737
) => {
38-
if (typeof type === 'string') {
38+
if (typeof type === 'string' || !type) {
3939
warning(
4040
true,
4141
'This way of calling useNotify callback is deprecated. Please use the new syntax passing notify("[Your message]", { ...restOfArguments })'
4242
);
4343
dispatch(
44-
showNotification(message, type || 'info', {
45-
messageArgs,
46-
undoable,
47-
autoHideDuration,
48-
multiLine,
49-
})
44+
showNotification(
45+
message,
46+
(type || 'info') as NotificationType,
47+
{
48+
messageArgs,
49+
undoable,
50+
autoHideDuration,
51+
multiLine,
52+
}
53+
)
5054
);
5155
} else {
5256
const { type: messageType, ...options } = type;

0 commit comments

Comments
 (0)