client/src/components/NoteInput.js
changeset 8 6f572b6b6be3
parent 5 5c91bfa8fcde
child 12 48ddaa42b810
--- a/client/src/components/NoteInput.js	Tue May 23 17:47:59 2017 +0200
+++ b/client/src/components/NoteInput.js	Wed May 31 18:08:22 2017 +0200
@@ -1,7 +1,6 @@
 import React, {Component} from 'react';
 
-import ReactDOM from 'react-dom'
-import { Form, FormControl, FormGroup, Button } from 'react-bootstrap';
+import { Form, FormGroup, Button } from 'react-bootstrap';
 
 import PropTypes from 'prop-types';
 import SlateEditor from './SlateEditor';
@@ -21,20 +20,18 @@
   }
 
   onAddNoteClick(event) {
-    const text = this.refs.editor.asPlain();
-    this.props.addNote(text);
-    this.refs.editor.clear();
-  }
-
-  componentDidMount() {
-    // this.noteInput.focus();
+    //const text = this.refs.editor.asPlain();
+    if(this.state.value && this.state.value.length > 0) {
+      this.props.addNote(this.state.value);
+      this.refs.editor.clear();
+    }
   }
 
   render() {
     return (
       <Form>
         <FormGroup>
-          <SlateEditor ref="editor" />
+          <SlateEditor ref="editor" onChange={this.handleChange} />
         </FormGroup>
         <Button type="button" onClick={this.onAddNoteClick}>Add Note</Button>
       </Form>