React에 통합하기

이 페이지는 설치 및 기본 사용에서 시작합니다. 아래의 구성 요소는 명시된 높이로 컨테이너에 Univer베이스를 마운트합니다.

통합 단계

  1. useEffect에서 Univer를 초기화합니다.
  2. useEffect cleanup에서 Univer를 해제합니다.

플러그인 설정

UniverUIPlugin

  • container
    string | HTMLElement
    편집기를 마운트할 DOM 요소 또는 해당 요소의 ID입니다.

UniverLicensePlugin

  • license
    string
    클라이언트 라이선스 파일의 내용입니다.

예제 코드

마운트할 때마다 전용 자식 컨테이너를 생성합니다. 외부 React 컴포넌트의 정리가 끝난 뒤 마이크로태스크에서 인스턴스를 해제합니다. 이렇게 하면 React 커밋 도중에 중첩된 React 루트가 동기적으로 언마운트되는 것을 방지할 수 있습니다.

TSX
import { useEffect, useRef } from 'react'import { UniverBasesPlugin } from '@univerjs-pro/bases'import { UniverBasesUIPlugin } from '@univerjs-pro/bases-ui'import BasesUIkoKR from '@univerjs-pro/bases-ui/locale/ko-KR'import BaseskoKR from '@univerjs-pro/bases/locale/ko-KR'import { UniverProFormulaEnginePlugin } from '@univerjs-pro/engine-formula'import { UniverLicensePlugin } from '@univerjs-pro/license'import { LocaleType, mergeLocales, Univer, UniverInstanceType } from '@univerjs/core'import DesignkoKR from '@univerjs/design/locale/ko-KR'import { UniverRenderEnginePlugin } from '@univerjs/engine-render'import { UniverUIPlugin } from '@univerjs/ui'import UIkoKR from '@univerjs/ui/locale/ko-KR'import '@univerjs/design/lib/index.css'import '@univerjs/ui/lib/index.css'import '@univerjs-pro/bases-ui/lib/index.css'export function UniverEditor() {  const containerRef = useRef<HTMLDivElement>(null)  useEffect(() => {    const host = containerRef.current    if (!host) return    const container = document.createElement('div')    container.style.height = '100%'    host.append(container)    const univer = new Univer({      locale: LocaleType.KO_KR,      locales: {        [LocaleType.KO_KR]: mergeLocales(          DesignkoKR,          UIkoKR,          BaseskoKR,          BasesUIkoKR,        ),      },    })    univer.registerPlugin(UniverLicensePlugin, {      license: 'your license.txt',    })    univer.registerPlugin(UniverRenderEnginePlugin)    univer.registerPlugin(UniverUIPlugin, { container })    univer.registerPlugin(UniverProFormulaEnginePlugin)    univer.registerPlugin(UniverBasesPlugin)    univer.registerPlugin(UniverBasesUIPlugin)    univer.createUnit(UniverInstanceType.UNIVER_BASE, {})    return () => {      queueMicrotask(() => {        univer.dispose()        container.remove()      })    }  }, [])  return <div ref={containerRef} style={{ height: 600 }} />}

이 가이드는 어떠셨나요?

© 2026 DreamNum Co., Ltd.