summaryrefslogtreecommitdiff
path: root/util/uniorg.tsx
blob: e35a021d925013da137969f3c7b8a9a46de28cb2 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import React, { useEffect, useState } from 'react'
import { NodeById } from '../pages/index'
import { ProcessedOrg } from './processOrg'

export interface UniOrgProps {
  nodeById: NodeById
  previewNode: any
  setPreviewNode: any
  getText: any
}

export const UniOrg = (props: UniOrgProps) => {
  const { nodeById, previewNode, setPreviewNode, getText } = props

  const [previewText, setPreviewText] = useState('')

  useEffect(() => {
    if (previewNode?.id) {
      getText(previewNode?.id, setPreviewText)
    }
  }, [previewNode?.id])

  return (
    <ProcessedOrg
      {...{
        getText,
        nodeById,
        previewNode,
        setPreviewNode,
        previewText,
      }}
    />
  )
}