Skip to content

Commit

Permalink
Slightly changed the code to be sure setIsSettingTextFromJS is only…
Browse files Browse the repository at this point in the history
… called when the text is actually set.
  • Loading branch information
daniloercoli committed Jun 29, 2018
1 parent 06d5d2e commit a08d774
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,21 @@ public Map<String, Object> getExportedCustomBubblingEventTypeConstants() {

@ReactProp(name = "text")
public void setText(ReactAztecText view, ReadableMap inputMap) {
view.setIsSettingTextFromJS(true);
if (!inputMap.hasKey("eventCount")) {
view.fromHtml(inputMap.getString("text"));
setTextfromJS(view, inputMap.getString("text"));
} else {
// Don't think there is necessity of this branch, but justin case we want to
// force a 2nd setText from JS side to Native, just set a high eventCount
int eventCount = inputMap.getInt("eventCount");
if (view.mNativeEventCount < eventCount) {
view.fromHtml(inputMap.getString("text"));
setTextfromJS(view, inputMap.getString("text"));
}
}
}

private void setTextfromJS(ReactAztecText view, String text) {
view.setIsSettingTextFromJS(true);
view.fromHtml(text);
view.setIsSettingTextFromJS(false);
}

Expand Down

0 comments on commit a08d774

Please sign in to comment.