Expo上的react原生富编辑器无法为功能组件提供参考



我正在尝试使用这个包:

https://www.npmjs.com/package/react-native-pell-rich-editor

我有以下代码:

import { useState, useRef } from "react";
import { RFPercentage } from "react-native-responsive-fontsize";
import BottomSheet from "@gorhom/bottom-sheet";
import {
StyleSheet,
View,
Text,
Platform,
KeyboardAvoidingView,
SafeAreaView,
ScrollView,
} from "react-native";
import {
actions,
RichEditor,
RichToolbar,
} from "react-native-pell-rich-editor";
export default function Publish() {
const postSheetRef = useRef(null);
const richText = useRef();
const snapPoints = ["90%"];

};
return (
<>
<View style={styles.container}>
<View style={styles.publishHeader}>
<Text style={styles.titleHeader}>Publier un post</Text>
</View>
<BottomSheet
ref={postSheetRef}
snapPoints={snapPoints}
handleIndicatorStyle={{ display: "none" }}
>
<View style={styles.main}>
<SafeAreaView>
<ScrollView>
<RichEditor
ref={richText}
onChange={(descriptionText) => {
console.log("descriptionText:", descriptionText);
}}
/>
</ScrollView>
<RichToolbar
editor={richText}
actions={[
actions.setBold,
actions.setItalic,
actions.setUnderline,
actions.heading1,
]}
iconMap={{
[actions.heading1]: ({ tintColor }) => (
<Text style={[{ color: tintColor }]}>H1</Text>
),
}}
/>
</SafeAreaView>
</View>
</BottomSheet>
</View>
</>
);
}

我得到这个错误:

Functional components cannot be given refs

它涉及富编辑器组件。

但我只是遵循了文档,所以我不明白为什么。

我将ref与底部工作表组件一起使用,它工作得很好。

我在世博会工作。

我该如何解决这个问题?这是我发现的唯一一个与Expo兼容的软件包,所以我需要让它发挥作用^^。

<RichEditor
ref={(r)=>{richText.current = r}}
onChange={(descriptionText) => {
console.log("descriptionText:", descriptionText);
}}
/>

最新更新