gtgalone / react-quilljs

React Hook Wrapper for Quill, powerful rich text editor.
https://www.npmjs.com/package/react-quilljs
MIT License
248 stars 28 forks source link

How to use formatLine or insertText? #19

Closed vbylen closed 3 years ago

vbylen commented 3 years ago

When using certain methods from the API such as:

quill.insertText(0, 'Hello', 'bold', true);

I am getting the following error:

'TypeError: Cannot read property 'insertText' of undefined'.

Any tips?

Awesome library by the way, thank you.

gtgalone commented 3 years ago

@10000multiplier Thank you for using!

At first rendering, quill is undefined.

And second rendering, quill has Quill object.

So you have to check if quill is undefined or not.

like below example,

https://github.com/gtgalone/react-quilljs#with-initial-value

vbylen commented 3 years ago

Yay it's working 😄