react-native-rich-editor icon indicating copy to clipboard operation
react-native-rich-editor copied to clipboard

Error: No overload matches this call. [ RN 0.72.3 + EXPO 49 + TS ]

Open matsyui opened this issue 2 years ago • 0 comments

Code:

import React, { useRef } from "react";
import { Text, Platform, KeyboardAvoidingView, SafeAreaView, ScrollView } from "react-native";
import { actions, RichEditor, RichToolbar } from "react-native-pell-rich-editor";


const handleHead = ({ tintColor }: { tintColor: string }) => <Text style={{ color: tintColor }}>H1</Text>
const TempScreen = () => {

    const richText = React.createRef() || useRef();

    return (
        <SafeAreaView>
            <ScrollView>
                <KeyboardAvoidingView behavior={Platform.OS === "ios" ? "padding" : "height"} style={{ flex: 1 }}>
                    <Text>Description:</Text>
                    <RichEditor
                        ref={richText}
                        onChange={descriptionText => {
                            console.log("descriptionText:", descriptionText);
                        }}
                    />
                </KeyboardAvoidingView>
            </ScrollView>

            <RichToolbar
                editor={richText}
                actions={[actions.setBold, actions.setItalic, actions.setUnderline, actions.heading1]}
                iconMap={{ [actions.heading1]: handleHead }}
            />
        </SafeAreaView>
    );
};

export default TempScreen;

Error:

No overload matches this call.
  Overload 1 of 2, '(props: RichEditorProps | Readonly<RichEditorProps>): RichEditor', gave the following error.
    Type 'RefObject<unknown>' is not assignable to type 'LegacyRef<RichEditor> | undefined'.
      Type 'RefObject<unknown>' is not assignable to type 'RefObject<RichEditor>'.
        Type 'unknown' is not assignable to type 'RichEditor'.
  Overload 2 of 2, '(props: RichEditorProps, context: any): RichEditor', gave the following error.
    Type 'RefObject<unknown>' is not assignable to type 'LegacyRef<RichEditor> | undefined'.ts(2769)
index.d.ts(125, 9): The expected type comes from property 'ref' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes<RichEditor> & Readonly<RichEditorProps>'
index.d.ts(125, 9): The expected type comes from property 'ref' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes<RichEditor> & Readonly<RichEditorProps>'

Versions:

{
  //other...
  "dependencies": {
     //other...
    "react-native-pell-rich-editor": "^1.9.0",
    "@types/react-dom": "^18.2.18",
    "expo": "49.0.3",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-native": "0.72.3",
    "react-native-webview": "^13.6.3",
  },
  "devDependencies": {
     //other...
    "@babel/core": "7.19.3",
    "@types/react": "^18.2.45",
    "@types/react-native": "0.72.2",
    "typescript": "5.0.2"
  }
}

matsyui avatar Dec 18 '23 04:12 matsyui