S
S
Smuzzzzi2018-11-06 02:05:24
React
Smuzzzzi, 2018-11-06 02:05:24

How to connect Sirtrevor Editor?

Sir Trevor

import React, {PureComponent} from 'react';
import SirTrevor from 'sir-trevor';

const editor = new SirTrevor.Editor({
  el: document.querySelector('.js-st-instance'),
  defaultType: 'Text',
  iconUrl: 'build/sir-trevor-icons.svg'
});
class Add extends PureComponent {
  render() {
    return (
     <div>
      <textarea class="js-st-instance"></textarea>
    </div>
    )
  }

I get an error
TypeError: Cannot read property 'nextSibling' of null

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Sokhin, 2018-11-06
@Smuzzzzi

Try to hang initialization on the event after mounting the data in the DOM

...
componentDidMount() {
  const { editorArea } = this.refs;
  const editor = new SirTrevor.Editor({
      el: editorArea,
      defaultType: 'Text',
      iconUrl: 'build/sir-trevor-icons.svg'
  });
}
  
render() {
  return (
      <div>
        <textarea className="js-st-instance" ref="editorArea"></textarea>
      </div>
    )
}
...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question