wix-incubator / react-native-zss-rich-text-editor

React Native rich text editor based on ZSSRichTextEditor
Other
841 stars 310 forks source link

Not able to access editor methods using ref #116

Open Prerna11082 opened 6 years ago

Prerna11082 commented 6 years ago

I am trying to use Rich text Editor methods like setBold(), setUnderline(), insertOrderedList() using editor ref. But it is throwing undefined error.

<RichTextEditor style={{flex:1, height:200}} ref={(r)=>this.richtext = r} hiddenTitle={true} contentPlaceholder="New Note" initialContentHTML={this.state.noteBody} editorInitializedCallback={() => this.onEditorInitialized()} /> <RichTextToolbar getEditor={() => this.richtext} renderAction={this._renderToolbarItem} actions={[ actions.setBold, actions.setItalic, actions.setUnderline, actions.insertBulletsList, actions.insertOrderedList ]} />

And in _renderToolbarItem(), I have rendered custom icons for each action. But in onPress of these icons, when I try to access this.richText.setBold(), it throws error undefined is not an object (evaluating 'this.richText.setBold')

vishaljani2 commented 6 years ago

You Have to import actions

Prerna11082 commented 6 years ago

I have already imported actions