Skip to content

Commit 5b63ab8

Browse files
Better Approach
1 parent c9ae68a commit 5b63ab8

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#import "RCTTextInputUtils.h"
2424

2525
#import "RCTFabricComponentsPlugins.h"
26+
#import <limits>
2627

2728
/** Native iOS text field bottom keyboard offset amount */
2829
static const CGFloat kSingleLineKeyboardBottomOffset = 15.0;
@@ -450,7 +451,7 @@ - (NSString *)textInputShouldChangeText:(NSString *)text inRange:(NSRange)range
450451
}
451452
}
452453

453-
if (props.maxLength) {
454+
if (props.maxLength != std::numeric_limits<int>::max()) {
454455
NSInteger allowedLength = props.maxLength - _backedTextInputView.attributedText.string.length + range.length;
455456

456457
if (allowedLength > 0 && text.length > allowedLength) {

packages/react-native/ReactCommon/react/renderer/components/textinput/BaseTextInputProps.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <react/renderer/components/view/ViewProps.h>
1414
#include <react/renderer/core/PropsParserContext.h>
1515
#include <react/renderer/graphics/Color.h>
16+
#include <limits>
1617
#include <string>
1718

1819
namespace facebook::react {
@@ -60,7 +61,7 @@ class BaseTextInputProps : public ViewProps, public BaseTextProps {
6061
// TODO: Rename to `tintColor` and make universal.
6162
SharedColor underlineColorAndroid{};
6263

63-
int maxLength{};
64+
int maxLength=std::numeric_limits<int>::max();
6465

6566
/*
6667
* "Private" (only used by TextInput.js) props

0 commit comments

Comments
 (0)