From b33eb44ebfd95b773cb0706d35e0f1cf87e3c261 Mon Sep 17 00:00:00 2001 From: Chris Brame Date: Sat, 9 Feb 2019 03:19:59 -0500 Subject: [PATCH] fix(component): easymde handle defaultValue --- src/client/components/EasyMDE/index.jsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/client/components/EasyMDE/index.jsx b/src/client/components/EasyMDE/index.jsx index 6b0766f95..f7b695b75 100644 --- a/src/client/components/EasyMDE/index.jsx +++ b/src/client/components/EasyMDE/index.jsx @@ -21,7 +21,8 @@ class EasyMDE extends React.Component { constructor (props) { super(props) this.state = { - value: '' + value: '', + loaded: false } } @@ -53,8 +54,13 @@ class EasyMDE extends React.Component { } static getDerivedStateFromProps (nextProps, state) { - if (nextProps.defaultValue) { - if (state.value === '' && nextProps.defaultValue !== state.value) return { value: nextProps.defaultValue } + if (typeof nextProps.defaultValue !== 'undefined') { + if (!state.loaded && nextProps.defaultValue !== state.value) + return { value: nextProps.defaultValue, loaded: true } + } else { + return { + loaded: true + } } return null