diff --git a/app/components/chat/BaseChat.tsx b/app/components/chat/BaseChat.tsx index e0eb41c..dd56edc 100644 --- a/app/components/chat/BaseChat.tsx +++ b/app/components/chat/BaseChat.tsx @@ -14,7 +14,7 @@ import { Workbench } from '~/components/workbench/Workbench.client'; import { classNames } from '~/utils/classNames'; interface BaseChatProps { - textareaRef?: React.RefObject | undefined; + textareaRef?: React.RefObject | undefined; messageRef?: RefCallback | undefined; scrollRef?: RefCallback | undefined; showChat?: boolean; diff --git a/app/components/editor/codemirror/CodeMirrorEditor.tsx b/app/components/editor/codemirror/CodeMirrorEditor.tsx index 96e4201..aedfd09 100644 --- a/app/components/editor/codemirror/CodeMirrorEditor.tsx +++ b/app/components/editor/codemirror/CodeMirrorEditor.tsx @@ -135,10 +135,10 @@ export const CodeMirrorEditor = memo( const [languageCompartment] = useState(new Compartment()); const containerRef = useRef(null); - const viewRef = useRef(); - const themeRef = useRef(); - const docRef = useRef(); - const editorStatesRef = useRef(); + const viewRef = useRef(undefined); + const themeRef = useRef(undefined); + const docRef = useRef(undefined); + const editorStatesRef = useRef(undefined); const onScrollRef = useRef(onScroll); const onChangeRef = useRef(onChange); const onSaveRef = useRef(onSave); diff --git a/app/components/ui/IconButton.tsx b/app/components/ui/IconButton.tsx index 9d58f58..f055d48 100644 --- a/app/components/ui/IconButton.tsx +++ b/app/components/ui/IconButton.tsx @@ -1,3 +1,5 @@ +import React from 'react'; +import type { ReactElement } from 'react'; import { memo } from 'react'; import { classNames } from '~/utils/classNames'; @@ -20,7 +22,7 @@ type IconButtonWithoutChildrenProps = { type IconButtonWithChildrenProps = { icon?: undefined; - children: string | JSX.Element | JSX.Element[]; + children: string | ReactElement | ReactElement[]; } & BaseIconButtonProps; type IconButtonProps = IconButtonWithoutChildrenProps | IconButtonWithChildrenProps; diff --git a/app/components/ui/PanelHeaderButton.tsx b/app/components/ui/PanelHeaderButton.tsx index 9faea1c..a35c79c 100644 --- a/app/components/ui/PanelHeaderButton.tsx +++ b/app/components/ui/PanelHeaderButton.tsx @@ -1,3 +1,5 @@ +import React from 'react'; +import type { ReactElement } from 'react'; import { memo } from 'react'; import { classNames } from '~/utils/classNames'; @@ -5,7 +7,7 @@ interface PanelHeaderButtonProps { className?: string; disabledClassName?: string; disabled?: boolean; - children: string | JSX.Element | Array; + children: string | ReactElement | Array; onClick?: (event: React.MouseEvent) => void; } diff --git a/app/components/ui/Slider.tsx b/app/components/ui/Slider.tsx index f332a6a..bde17fe 100644 --- a/app/components/ui/Slider.tsx +++ b/app/components/ui/Slider.tsx @@ -1,8 +1,10 @@ +import React from 'react'; import { motion } from 'framer-motion'; import { memo } from 'react'; import { classNames } from '~/utils/classNames'; import { cubicEasingFn } from '~/utils/easings'; import { genericMemo } from '~/utils/react'; +import type { ReactElement } from 'react'; interface SliderOption { value: T; @@ -37,7 +39,7 @@ export const Slider = genericMemo(({ selected, options, setSelected }: Slide interface SliderButtonProps { selected: boolean; - children: string | JSX.Element | Array; + children: string | ReactElement | Array; setSelected: () => void; } diff --git a/app/components/workbench/FileBreadcrumb.tsx b/app/components/workbench/FileBreadcrumb.tsx index 1f7434d..465457b 100644 --- a/app/components/workbench/FileBreadcrumb.tsx +++ b/app/components/workbench/FileBreadcrumb.tsx @@ -87,7 +87,9 @@ export const FileBreadcrumb = memo(({ files, pathSegments = (segmentRefs.current[index] = ref)} + ref={(ref) => { + segmentRefs.current[index] = ref; + }} className={classNames('flex items-center gap-1.5 cursor-pointer shrink-0', { 'text-bolt-elements-textTertiary hover:text-bolt-elements-textPrimary': !isActive, 'text-bolt-elements-textPrimary underline': isActive, diff --git a/app/components/workbench/terminal/Terminal.tsx b/app/components/workbench/terminal/Terminal.tsx index 790aed5..d56a4df 100644 --- a/app/components/workbench/terminal/Terminal.tsx +++ b/app/components/workbench/terminal/Terminal.tsx @@ -23,7 +23,7 @@ export interface TerminalProps { export const Terminal = memo( forwardRef(({ className, theme, readonly, onTerminalReady, onTerminalResize }, ref) => { const terminalElementRef = useRef(null); - const terminalRef = useRef(); + const terminalRef = useRef(null); useEffect(() => { const element = terminalElementRef.current!; diff --git a/app/lib/hooks/useSnapScroll.ts b/app/lib/hooks/useSnapScroll.ts index 5c1565a..77efbf3 100644 --- a/app/lib/hooks/useSnapScroll.ts +++ b/app/lib/hooks/useSnapScroll.ts @@ -2,9 +2,9 @@ import { useRef, useCallback } from 'react'; export function useSnapScroll() { const autoScrollRef = useRef(true); - const scrollNodeRef = useRef(); - const onScrollRef = useRef<() => void>(); - const observerRef = useRef(); + const scrollNodeRef = useRef(null); + const onScrollRef = useRef<(() => void) | null>(null); + const observerRef = useRef(null); const messageRef = useCallback((node: HTMLDivElement | null) => { if (node) { @@ -22,7 +22,7 @@ export function useSnapScroll() { observer.observe(node); } else { observerRef.current?.disconnect(); - observerRef.current = undefined; + observerRef.current = null; } }, []); @@ -43,8 +43,8 @@ export function useSnapScroll() { scrollNodeRef.current?.removeEventListener('scroll', onScrollRef.current); } - scrollNodeRef.current = undefined; - onScrollRef.current = undefined; + scrollNodeRef.current = null; + onScrollRef.current = null; } }, []); diff --git a/app/routes/webcontainer.preview.$id.tsx b/app/routes/webcontainer.preview.$id.tsx index c693c25..518e188 100644 --- a/app/routes/webcontainer.preview.$id.tsx +++ b/app/routes/webcontainer.preview.$id.tsx @@ -17,7 +17,7 @@ export async function loader({ params }: LoaderFunctionArgs) { export default function WebContainerPreview() { const { previewId } = useLoaderData(); const iframeRef = useRef(null); - const broadcastChannelRef = useRef(); + const broadcastChannelRef = useRef(null); const [previewUrl, setPreviewUrl] = useState(''); // handle preview refresh diff --git a/app/utils/react.ts b/app/utils/react.ts index f5d2b02..6852bb9 100644 --- a/app/utils/react.ts +++ b/app/utils/react.ts @@ -1,6 +1,7 @@ +import type { ComponentProps, ComponentType, JSXElementConstructor } from 'react'; import { memo } from 'react'; -export const genericMemo: >( - component: T, - propsAreEqual?: (prevProps: React.ComponentProps, nextProps: React.ComponentProps) => boolean, -) => T & { displayName?: string } = memo; +export const genericMemo: >( + Component: T, + propsAreEqual?: (prevProps: ComponentProps, nextProps: ComponentProps) => boolean, +) => T = memo;