From 6b62e71b4b6d4e10abf5a88a262d6b7b7b43a792 Mon Sep 17 00:00:00 2001 From: mks11 Date: Mon, 9 Jan 2017 07:50:19 +0530 Subject: [PATCH 1/2] using newer 'ref' syntax --- examples/draft-0-10-0/plaintext/plaintext.html | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/draft-0-10-0/plaintext/plaintext.html b/examples/draft-0-10-0/plaintext/plaintext.html index 3e8f0c4fb7..e86121ad40 100644 --- a/examples/draft-0-10-0/plaintext/plaintext.html +++ b/examples/draft-0-10-0/plaintext/plaintext.html @@ -35,12 +35,14 @@ constructor(props) { super(props); this.state = {editorState: EditorState.createEmpty()}; - - this.focus = () => this.refs.editor.focus(); this.onChange = (editorState) => this.setState({editorState}); this.logState = () => console.log(this.state.editorState.toJS()); } - + + componentDidMount(){ + this.domEditor.focus() + } + render() { return (
@@ -49,7 +51,7 @@ editorState={this.state.editorState} onChange={this.onChange} placeholder="Enter some text..." - ref="editor" + ref={(d)=>{this.domEditor = d}} />
Date: Mon, 17 Jul 2017 12:10:09 +0530 Subject: [PATCH 2/2] commit based on the feedback --- examples/draft-0-10-0/plaintext/plaintext.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/draft-0-10-0/plaintext/plaintext.html b/examples/draft-0-10-0/plaintext/plaintext.html index e86121ad40..61275df021 100644 --- a/examples/draft-0-10-0/plaintext/plaintext.html +++ b/examples/draft-0-10-0/plaintext/plaintext.html @@ -37,8 +37,9 @@ this.state = {editorState: EditorState.createEmpty()}; this.onChange = (editorState) => this.setState({editorState}); this.logState = () => console.log(this.state.editorState.toJS()); + this.setDomEditorRef = ref => this.domEditor = ref; } - + componentDidMount(){ this.domEditor.focus() } @@ -51,7 +52,7 @@ editorState={this.state.editorState} onChange={this.onChange} placeholder="Enter some text..." - ref={(d)=>{this.domEditor = d}} + ref={this.setDomEditorRef} />