import React, { createContext, useEffect, useState } from 'react'; import { useSelector } from 'react-redux'; import { AppActions, RootState } from './store'; import { ToastContainer } from 'react-toastify'; import { Box } from 'lr-components'; import AppActionHook from './components/AppActionHook'; import { isEnvBrowser } from './utils/misc'; import { fetchNui } from './utils/fetchNui'; import { DefaultUISetting, ISettingContext, UISetting } from './types'; const SettingContext = createContext(DefaultUISetting); function App() { const show = useSelector((state: RootState) => state.main.show); const [setting, setSetting] = useState({ locale: {} }); const L = (key: string) => setting.locale[key] || key; useEffect(() => { if (!isEnvBrowser()) { setTimeout(async () => { const UISetting = await fetchNui('AppReady'); setSetting(UISetting); }, 2000); } }, [setSetting]); return ( {Object.keys(AppActions).map((action) => { return ( ); })} {show && ( )} ); } export default App;