From 1b3457474265be6251c1ad2fc8bb51365b2f3bda Mon Sep 17 00:00:00 2001 From: Julia Qiu Date: Sun, 5 Apr 2020 18:09:34 -0700 Subject: [PATCH] Fix server side rendering Defer `document.getSelection()` to `cDM` so the component can be rendered on the server side. --- src/react-sane-contenteditable.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/react-sane-contenteditable.js b/src/react-sane-contenteditable.js index e9fa892..b35732a 100644 --- a/src/react-sane-contenteditable.js +++ b/src/react-sane-contenteditable.js @@ -53,10 +53,11 @@ class ContentEditable extends Component { }; this.ref = null; - this.selection = document.getSelection(); } componentDidMount() { + this.selection = document.getSelection(); + const { focus } = this.props; if (focus && this.ref) {