import React, { useRef, useEffect, useContext, Suspense } from 'react'; import { useTranslation } from 'react-i18next'; import { PanZoom } from 'react-easy-panzoom'; import AppContext from '../../context/AppContext'; import PageContext from '../../context/PageContext'; import LeftSidebar from '../LeftSidebar/LeftSidebar'; import RightSidebar from '../RightSidebar/RightSidebar'; import templates from '../../templates'; import PageController from '../../shared/PageController'; import PrintDialog from '../../shared/PrintDialog'; const App = () => { const pageRef = useRef(null); const panZoomRef = useRef(null); const { i18n } = useTranslation(); const context = useContext(AppContext); const { state, dispatch } = context; const { theme, settings } = state; const pageContext = useContext(PageContext); const { setPageRef, setPanZoomRef } = pageContext; useEffect(() => { setPageRef(pageRef); setPanZoomRef(panZoomRef); i18n.changeLanguage(settings.language); const storedState = JSON.parse(localStorage.getItem('state')); dispatch({ type: 'import_data', payload: storedState }); }, [dispatch, setPageRef, setPanZoomRef, i18n, settings.language]); return (
{templates.find((x) => theme.layout.toLowerCase() === x.key).component()}
); }; export default App;