react-native-rich-editor
react-native-rich-editor copied to clipboard
Typescript for custom actions
How can i handle RichToolbar component typescript when adding new actions?
The following is my custom component, typescript don't accept hideContent
props, since it was not declared.
<RichToolbar
editor={richText}
actions={[
actions.setBold,
actions.setItalic,
actions.setUnderline,
'hideContent',
]}
iconMap={{
hideContent: ({ tintColor }) => (
<MaterialCommunityIcons name="eye" color={tintColor} />
),
}}
hideContent={() => richText.current.insertText('{{ HIDDEN }}')}
/>
@gabrielbuzziv Do you want to fire new action when hideContent
Icon pressed?
Then, how about trying onPress
property in your custom iconMap
.
...
iconMap={{
hideContent: ({ tintColor }) => (
<TouchableOpacity onPress={this.handleFunction}>
<MaterialCommunityIcons name="eye" color={tintColor} />
</TouchableOpacity>
),
}}
...
I wanted to apply a function to handle new action, but customAction
property which doc suggest is not working and even has not a type.