--- a/client/src/components/Note.js Tue Nov 06 16:19:26 2018 +0100
+++ b/client/src/components/Note.js Thu Nov 08 16:03:28 2018 +0100
@@ -6,6 +6,18 @@
class Note extends Component {
+ constructor(props) {
+ super(props);
+ this.editorInst = React.createRef();
+ }
+
+ get editor() {
+ if(this.editorInst && this.editorInst.current) {
+ return this.editorInst.current;
+ }
+ return null;
+ }
+
onClickDelete = (e) => {
e.preventDefault();
e.stopPropagation();
@@ -15,10 +27,10 @@
onClickButton = (e) => {
- const plain = this.refs.editor.asPlain();
- const raw = this.refs.editor.asRaw();
- const html = this.refs.editor.asHtml();
- const categories = this.refs.editor.asCategories();
+ const plain = this.editor.asPlain();
+ const raw = this.editor.asRaw();
+ const html = this.editor.asHtml();
+ const categories = this.editor.asCategories();
// const marginComment = this.marginComment.value;
const data = {
@@ -43,7 +55,7 @@
if (this.props.isEditing) {
return (
<div className="note-content w-100 pl-2 pt-2">
- <SlateEditor ref="editor"
+ <SlateEditor editorRef={this.editorInst}
onButtonClick={ this.onClickButton }
note={ this.props.note }
annotationCategories={ this.props.annotationCategories } />