Difference between onEndEditing and onBlur?

First let me say I was struggling finding the answer to this question!

I believe this is rooted in history since it originates from iOS which has the native event UIControlEventEditingDidEnd. That’s probably the naming before blur was introduced as an abstraction.

TL:DR;

onEndEditing should really be deprecated in my opinion, but as of right now you should use it because it is the most platform agnostic version of blur. See below.

Both onBlur and onEndEditing get an event. On iOS both of these seem to do the exact same thing, and the event has the native text. In Android, it is two different events, and only one of them has access to the text. To me this seems like a bug.

Notice the differences between Android onEndEditing and Android onBlur.

// this is undefined on Android
onBlur={(e) => alert(e.nativeEvent.text)}

So if reading the text during a blur, you get cross-platform usability with onEndEditing for now.

See this rnplay to see the differences in OS

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)