Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a nil check to prevent a crash (#35941)
Summary: This is a [change](microsoft#1120) we made in our fork (React Native macOS) that we are now upstreaming to reduce the number of diffs between React Native Core and React Native macOS. Also.. one less crash �! Resolves microsoft#1679 Original PR notes: > We've seen a crash downstream where -[NSString stringByReplacingCharactersInRange:withString:] receives a nil value as the replacement string. This is not good, since we expect that argument to be non-null. > >We believe that a cause of this is that -[RCTUITextField textView:shouldChangeTextInRange:replacementString:] is being called with nil as the replacement string. (This is legal, as per [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextviewdelegate/1449325-textview?language=objc).) Right now, the only check that this delegate method does is enforcing the maxLength parameter if it exists, and changes in attributes shouldn't affect the length of the string. ## Changelog [IOS] [FIXED] - `-[RCTUITextField textView:shouldChangeTextInRange:replacementString:]` no longer crashes when we pass in a `nil` replacement string Pull Request resolved: #35941 Test Plan: Build should pass. This change has been running in our fork in production for a while so we're fairly confident of it. Reviewed By: cipolleschi Differential Revision: D42705382 Pulled By: jacdebug fbshipit-source-id: 066cd8a4ba134a681f0f4c955594b1fcda61a30e
- Loading branch information