We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents fc1a051 + 070b484 commit 2323f14Copy full SHA for 2323f14
1 file changed
src/@next/Alert/AlertProvider.tsx
@@ -1,13 +1,16 @@
1
-import React, { useState } from 'react';
+import React, { useCallback, useState } from 'react';
2
import { AlertProps } from './Alert';
3
import { AlertContext, ShowAlertProps } from './AlertContext';
4
5
export const AlertProvider = ({ children }: { children: React.ReactNode }) => {
6
const [state, setState] = useState<AlertProps>({ show: false });
7
8
- const open = (props: ShowAlertProps) => setState({ ...props, show: true });
+ const open = useCallback(
9
+ (props: ShowAlertProps) => setState({ ...props, show: true }),
10
+ [setState]
11
+ );
12
- const close = () => setState({ show: false });
13
+ const close = useCallback(() => setState({ show: false }), [setState]);
14
15
const alertContextValue = { ...state, open, close };
16
0 commit comments