import React, { ForwardedRef, forwardRef, useImperativeHandle, useState } from "react"; interface ComponentStyle { mainColor?: string; subColor?: string; } export interface ComponentProps { style?: ComponentStyle; } export interface ComponentRef { updateConfig: (config: ComponentProps) => void; } const Index = forwardRef((props: ComponentProps, ref: ForwardedRef) => { const [style, setStyle] = useState({ ...props.style }); const { mainColor = "#83BFF6", subColor = "#00CED1" } = style || {}; useImperativeHandle(ref, () => ({ updateConfig: (newConfig) => setStyle({ ...newConfig.style }), })); return
; }); export default Index;