pell
pell copied to clipboard
Update React example to use React.createRef
import 'pell/dist/pell.css'
import React, { Component } from 'react';
import { init } from 'pell';
export default class App extends Component {
state = { html: null }
root = React.createRef()
componentDidMount () {
this.editor = init({
element: this.root.current,
onChange: html => this.setState({ html }),
actions: ['bold', 'underline', 'italic'],
})
}
render() {
return (
<div className="App">
<h3>Editor:</h3>
<div ref={this.root} className="pell" />
<h3>HTML Output:</h3>
<div>{this.state.html}</div>
</div>
);
}
}
Why?
element: document.getElementById('editor')
Is not bound to the instance of the component. So one would not be able to have 2 App Components on the page.