diff --git a/packages/web-react/src/components/FileUploader/useFileUploaderAttachment.ts b/packages/web-react/src/components/FileUploader/useFileUploaderAttachment.ts index 65887db2e7..daec6140db 100644 --- a/packages/web-react/src/components/FileUploader/useFileUploaderAttachment.ts +++ b/packages/web-react/src/components/FileUploader/useFileUploaderAttachment.ts @@ -1,4 +1,5 @@ -import { RefObject, useLayoutEffect } from 'react'; +import { RefObject } from 'react'; +import { useIsomorphicLayoutEffect } from '../../hooks'; import { FileMetadata } from '../../types/fileUploader'; import { getAttachmentInput, getAttachmentMetaInput } from './utils'; @@ -17,7 +18,7 @@ export const useFileUploaderAttachment = ({ meta, onError, }: UseFileUploaderAttachmentProps) => { - useLayoutEffect(() => { + useIsomorphicLayoutEffect(() => { const createAttachmentInput = (metadata: FileMetadata) => { attachmentRef.current?.querySelectorAll('input').forEach((element) => element.remove()); const attachmentInputElement = getAttachmentInput(file, name, onError); diff --git a/packages/web-react/src/hooks/useClickOutside.ts b/packages/web-react/src/hooks/useClickOutside.ts index 3f501a3a1c..605547eb9b 100644 --- a/packages/web-react/src/hooks/useClickOutside.ts +++ b/packages/web-react/src/hooks/useClickOutside.ts @@ -1,4 +1,5 @@ -import { useLayoutEffect, useCallback, MutableRefObject } from 'react'; +import { MutableRefObject, useCallback } from 'react'; +import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect'; export interface UseClickOutsideProps { ref: MutableRefObject; @@ -34,7 +35,7 @@ export const useClickOutside = ({ ref, callback }: UseClickOutsideProps): void = [ref, callback], ); - useLayoutEffect(() => { + useIsomorphicLayoutEffect(() => { document.addEventListener('click', clickHandler, { capture: true }); return () => document.removeEventListener('click', clickHandler, { capture: true });