File size: 754 Bytes
3d4392e
 
 
 
0d218b1
3d4392e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
35
36
"use client"

import { useEffect, useState } from "react";

import { ClapProject, ClapSegment } from "@aitube/clap";
import { resolveSegment } from "./resolveSegment";

export function LatentComponent({
  segment,
  clap
}: {
  segment: ClapSegment,
  clap: ClapProject
}): JSX.Element {
  const [component, setComponent] = useState<JSX.Element | null>(null)
  const [isInitialized, setInitialized] = useState(false)
  const [isLoaded, setLoaded] = useState(false)

  useEffect(() => {
    if (isInitialized) { return }
    setInitialized(true)

    const fn = async () => {
      const component = await resolveSegment(segment, clap)

      setComponent(component)
    }

    fn()

    return () => {}
  }, [isInitialized])


  return <>{component}</>
}