mirror of
https://github.com/langgenius/dify.git
synced 2026-05-06 02:18:08 +08:00
fix: use ref not set init value
This commit is contained in:
@ -14,7 +14,7 @@ type FeaturesProviderProps = {
|
||||
children: React.ReactNode
|
||||
} & Partial<FeaturesState>
|
||||
export const FeaturesProvider = ({ children, ...props }: FeaturesProviderProps) => {
|
||||
const storeRef = useRef<FeaturesStore>()
|
||||
const storeRef = useRef<FeaturesStore | undefined>(undefined)
|
||||
|
||||
if (!storeRef.current)
|
||||
storeRef.current = createFeaturesStore(props)
|
||||
|
||||
@ -54,7 +54,7 @@ export const FileContextProvider = ({
|
||||
value,
|
||||
onChange,
|
||||
}: FileProviderProps) => {
|
||||
const storeRef = useRef<FileStore>()
|
||||
const storeRef = useRef<FileStore | undefined>(undefined)
|
||||
|
||||
if (!storeRef.current)
|
||||
storeRef.current = createFileStore(value, onChange)
|
||||
|
||||
@ -40,7 +40,7 @@ const Flowchart = (
|
||||
|
||||
const prevPrimitiveCode = usePrevious(props.PrimitiveCode)
|
||||
const [isLoading, setIsLoading] = useState(true)
|
||||
const timeRef = useRef<number>()
|
||||
const timeRef = useRef<number>(0)
|
||||
const [errMsg, setErrMsg] = useState('')
|
||||
const [imagePreviewUrl, setImagePreviewUrl] = useState('')
|
||||
|
||||
@ -119,22 +119,22 @@ const Flowchart = (
|
||||
</div>
|
||||
{
|
||||
svgCode
|
||||
&& <div className="mermaid cursor-pointer h-auto w-full object-fit: cover" onClick={() => setImagePreviewUrl(svgCode)}>
|
||||
{svgCode && <img src={svgCode} alt="mermaid_chart" />}
|
||||
</div>
|
||||
&& <div className="mermaid cursor-pointer h-auto w-full object-fit: cover" onClick={() => setImagePreviewUrl(svgCode)}>
|
||||
{svgCode && <img src={svgCode} alt="mermaid_chart" />}
|
||||
</div>
|
||||
}
|
||||
{isLoading
|
||||
&& <div className='py-4 px-[26px]'>
|
||||
<LoadingAnim type='text'/>
|
||||
</div>
|
||||
&& <div className='py-4 px-[26px]'>
|
||||
<LoadingAnim type='text' />
|
||||
</div>
|
||||
}
|
||||
{
|
||||
errMsg
|
||||
&& <div className='py-4 px-[26px]'>
|
||||
<ExclamationTriangleIcon className='w-6 h-6 text-red-500'/>
|
||||
|
||||
{errMsg}
|
||||
</div>
|
||||
&& <div className='py-4 px-[26px]'>
|
||||
<ExclamationTriangleIcon className='w-6 h-6 text-red-500' />
|
||||
|
||||
{errMsg}
|
||||
</div>
|
||||
}
|
||||
{
|
||||
imagePreviewUrl && (<ImagePreview title='mermaid_chart' url={imagePreviewUrl} onCancel={() => setImagePreviewUrl('')} />)
|
||||
|
||||
Reference in New Issue
Block a user