Reputation: 33
version "react": "16.11.0", "react-native": "0.62.2",
https://reactnative.dev/docs/textinput#numberoflines
If you look at the React Native documents, This feature is available.
this my code
But, not working
How can limit the lines?
Upvotes: 0
Views: 1185
Reputation: 1733
maybe the the property doesn't set a maximum number of lines, but here's an alternative
// set the max lines
const MAX_LINES = 3
// method to handle the text change
onTextFieldChange = (text) => {
if ( text.split(/\r\n|\r|\n/).length <= MAX_LINES )
{
this.setState({text});
}
}
// on your textInput
<TextInput
// properties...
onTextChange={this.onTextInputChange}
/>
Upvotes: 2