Skip to content

Commit 3679b56

Browse files
committed
Fix #49: Update FormInstance data with initial synced data
1 parent f3a1093 commit 3679b56

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/renderer.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ export function FormInstance(config) {
1818

1919
this.eventListeners = null;
2020

21+
this._dataSynced = false;
22+
2123
this.addEventListener = function(event, listener) {
2224
if (this.eventListeners === null)
2325
this.eventListeners = {};
@@ -31,6 +33,12 @@ export function FormInstance(config) {
3133
this.onChange = function(e) {
3234
this.data = e.data;
3335

36+
if (!this._dataSynced) {
37+
// this is the first change event for syncing data
38+
this._dataSynced = true;
39+
return;
40+
}
41+
3442
if (!this.eventListeners)
3543
return;
3644

@@ -118,6 +126,7 @@ export class FormContainer extends React.Component {
118126
}
119127

120128
componentDidMount() {
129+
this.props.onChange({data: this.state.editorState.getData()});
121130
this.populateDataInput(this.state.editorState.getData());
122131
}
123132

0 commit comments

Comments
 (0)