@@ -7,12 +7,14 @@ import { useTranslation } from 'react-i18next';
77import { useNavigate } from 'react-router-dom' ;
88
99import { useAsync , useMount , useStorage } from '@react-devui/hooks' ;
10+ import { DNotification , DToast } from '@react-devui/ui' ;
1011import { DRoot } from '@react-devui/ui' ;
1112
1213import { AppRoutes } from './Routes' ;
1314import { LOGIN_PATH } from './config/other' ;
1415import { STORAGE_KEY } from './config/storage' ;
1516import { useHttp , useInit } from './core' ;
17+ import { useNotifications , useToasts } from './core/state' ;
1618
1719export type AppTheme = 'light' | 'dark' ;
1820
@@ -25,6 +27,8 @@ export function App() {
2527 const [ loading , setLoading ] = useState ( true ) ;
2628 const languageStorage = useStorage < DLang > ( ...STORAGE_KEY . language ) ;
2729 const themeStorage = useStorage < AppTheme > ( ...STORAGE_KEY . theme ) ;
30+ const [ notifications ] = useNotifications ( ) ;
31+ const [ toasts ] = useToasts ( ) ;
2832
2933 useMount ( ( ) => {
3034 i18n . changeLanguage ( languageStorage . value ) ;
@@ -77,7 +81,17 @@ export function App() {
7781 [ languageStorage . value ]
7882 ) ;
7983
80- return < DRoot context = { rootContext } > { loading ? null : < AppRoutes /> } </ DRoot > ;
84+ return (
85+ < DRoot context = { rootContext } >
86+ { loading ? null : < AppRoutes /> }
87+ { notifications . map ( ( { key, ...props } ) => (
88+ < DNotification { ...props } key = { key } > </ DNotification >
89+ ) ) }
90+ { toasts . map ( ( { key, ...props } ) => (
91+ < DToast { ...props } key = { key } > </ DToast >
92+ ) ) }
93+ </ DRoot >
94+ ) ;
8195}
8296
8397export default App ;
0 commit comments