You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you use a function component instead of a class component, there is a type error on the functional component., if you are using Typescript.
The error is the same as this one: expo/router#278
Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()
To Reproduce
Steps to reproduce the behavior:
Use component like so:
importEditorComponent,{DiffEditor,useMonaco,loader,}from'@monaco-editor/react'import{useEffect,useRef}from'react'exportfunctionEditor(){consteditorRef=useRef<typeofEditorComponent>(null)useEffect(()=>{editorRef.current?.getValue()})return(<EditorComponentref={editorRef}height="90vh"defaultLanguage="typescriptreact"defaultValue="// some comment"theme="dark"/>)}
The text was updated successfully, but these errors were encountered:
Robbie-Cook
changed the title
Using ref using a function component gives an error
Using ref using a function component gives an error: Function components cannot be given refs.
Jan 23, 2025
Robbie-Cook
changed the title
Using ref using a function component gives an error: Function components cannot be given refs.
Using ref using a function component gives a type error: Function components cannot be given refs.
Jan 23, 2025
Describe the bug
If you use a function component instead of a class component, there is a type error on the functional component., if you are using Typescript.
The error is the same as this one: expo/router#278
To Reproduce
Steps to reproduce the behavior:
Use component like so:
The text was updated successfully, but these errors were encountered: