overleaf/services/web/frontend/js/features/ide-react/components/history.tsx
Alf Eaton 0dfb4d8de6 Lazy-load the React History view (#17290)
GitOrigin-RevId: 6d6ee5e993658e0895d9c2bcd4c2f60bba86c04e
2024-02-27 17:02:01 +00:00

28 lines
937 B
TypeScript

import { createPortal } from 'react-dom'
import HistoryFileTree from '@/features/history/components/history-file-tree'
import LoadingSpinner from '@/shared/components/loading-spinner'
import DiffView from '@/features/history/components/diff-view/diff-view'
import ChangeList from '@/features/history/components/change-list/change-list'
import { useHistoryContext } from '@/features/history/context/history-context'
export default function History() {
const { updatesInfo } = useHistoryContext()
const fileTreeContainer = document.getElementById('history-file-tree')
return (
<>
{fileTreeContainer &&
createPortal(<HistoryFileTree />, fileTreeContainer)}
<div className="history-react">
{updatesInfo.loadingState === 'loadingInitial' ? (
<LoadingSpinner />
) : (
<>
<DiffView />
<ChangeList />
</>
)}
</div>
</>
)
}