chore: ref not set value

This commit is contained in:
Joel 2025-03-19 16:05:14 +08:00
parent d50d5d92a1
commit 7a6eba70bf
6 changed files with 17 additions and 17 deletions

View File

@ -14,7 +14,7 @@ type FeaturesProviderProps = {
children: React.ReactNode children: React.ReactNode
} & Partial<FeaturesState> } & Partial<FeaturesState>
export const FeaturesProvider = ({ children, ...props }: FeaturesProviderProps) => { export const FeaturesProvider = ({ children, ...props }: FeaturesProviderProps) => {
const storeRef = useRef<FeaturesStore>() const storeRef = useRef<FeaturesStore | undefined>(undefined)
if (!storeRef.current) if (!storeRef.current)
storeRef.current = createFeaturesStore(props) storeRef.current = createFeaturesStore(props)

View File

@ -54,7 +54,7 @@ export const FileContextProvider = ({
value, value,
onChange, onChange,
}: FileProviderProps) => { }: FileProviderProps) => {
const storeRef = useRef<FileStore>() const storeRef = useRef<FileStore | undefined>(undefined)
if (!storeRef.current) if (!storeRef.current)
storeRef.current = createFileStore(value, onChange) storeRef.current = createFileStore(value, onChange)

View File

@ -41,7 +41,7 @@ const Flowchart = (
const prevPrimitiveCode = usePrevious(props.PrimitiveCode) const prevPrimitiveCode = usePrevious(props.PrimitiveCode)
const [isLoading, setIsLoading] = useState(true) const [isLoading, setIsLoading] = useState(true)
const timeRef = useRef<number>() const timeRef = useRef<number>(0)
const [errMsg, setErrMsg] = useState('') const [errMsg, setErrMsg] = useState('')
const [imagePreviewUrl, setImagePreviewUrl] = useState('') const [imagePreviewUrl, setImagePreviewUrl] = useState('')
@ -126,13 +126,13 @@ const Flowchart = (
} }
{isLoading {isLoading
&& <div className='py-4 px-[26px]'> && <div className='py-4 px-[26px]'>
<LoadingAnim type='text'/> <LoadingAnim type='text' />
</div> </div>
} }
{ {
errMsg errMsg
&& <div className='py-4 px-[26px]'> && <div className='py-4 px-[26px]'>
<ExclamationTriangleIcon className='w-6 h-6 text-red-500'/> <ExclamationTriangleIcon className='w-6 h-6 text-red-500' />
&nbsp; &nbsp;
{errMsg} {errMsg}
</div> </div>

View File

@ -150,7 +150,7 @@ export const PortalToFollowElemContent = (
style, style,
...props ...props
}: React.HTMLProps<HTMLDivElement> & { }: React.HTMLProps<HTMLDivElement> & {
ref: React.RefObject<HTMLDivElement>; ref?: React.RefObject<HTMLDivElement>;
}, },
) => { ) => {
const context = usePortalToFollowElemContext() const context = usePortalToFollowElemContext()

View File

@ -11,7 +11,7 @@ type WorkflowProviderProps = {
children: React.ReactNode children: React.ReactNode
} }
export const WorkflowContextProvider = ({ children }: WorkflowProviderProps) => { export const WorkflowContextProvider = ({ children }: WorkflowProviderProps) => {
const storeRef = useRef<WorkflowStore>() const storeRef = useRef<WorkflowStore | undefined>(undefined)
if (!storeRef.current) if (!storeRef.current)
storeRef.current = createWorkflowStore() storeRef.current = createWorkflowStore()

View File

@ -43,7 +43,7 @@ const defaultSubcribeOption: UseSubcribeOption = {
function useMitt<Events extends _Events>( function useMitt<Events extends _Events>(
mitt?: Emitter<Events>, mitt?: Emitter<Events>,
): UseMittReturn<Events> { ): UseMittReturn<Events> {
const emitterRef = useRef<Emitter<Events>>() const emitterRef = useRef<Emitter<Events> | undefined>(undefined)
if (!emitterRef.current) if (!emitterRef.current)
emitterRef.current = mitt ?? create<Events>() emitterRef.current = mitt ?? create<Events>()