Accepted answer

I finally got the answer it turns out that in react there is an event called onBeforeInput that can be used on contenteditable divs and has a property called data that corresponds to the text that is going to be inserted (on both mobile and desktop). this event is cancelable so you can call preventDefault on it and update your state. unfortunately this event was not mentioned in any of react docs (!!) and I found it from an issue on their github repo.

Related Query

More Query from same tag