Most built-in apps on iPhones are equipped with the Shake to Undo feature, which allows users to undo text typing by simply shaking their device, and selecting the Undo Typing confirmation box. If you do not want to take advantage of this feature, here's a quick tip to disable the Shake to Undo feature.
How To Disable the Shake to Undo Feature
Go to Settings > General > Accessibility > Shake to Undo. Toggle Shake to Undo to Off.
N.B. Unless you are running on iOS 9 or using a jailbroken device, the Shake to Undo feature is impossible to turn off. In order to disable the feature, your device should be upgraded to iOS 9.