2

I'm wondering why numberOfLines won't set a limit of six lines while maxLength does work on the same TextInput and limits the user's input to 140 char.

Here's my code (simplified):

<TextInput
              maxLength={140}
              multiline={true}
              numberOfLines={6}
/>
Maulana Prambadi
  • 1,015
  • 9
  • 7
JoeBeCool
  • 42
  • 2
  • 11

3 Answers3

1

I leave you with the TextInput React-Native documentation so you can check your current implementation, it is suggested to use multiline set to true, this could be causing the problem

<TextInput
  maxLength = {140}
  numberOfLines = {6}
  multiline={true} 
/>

Hope it helps

Andre Breton
  • 1,273
  • 1
  • 9
  • 19
0

From the React-Native Text Input docs;

numberOfLines?: number #

Sets the number of lines for a TextInput. Use it with multiline set to true to be able to fill the lines.

Did you set multiline prop to true?

bennygenel
  • 23,896
  • 6
  • 65
  • 78
  • Ok! I think I understood you wrong. numberOfLines doesn't supposed to limit the line number. It sets the initial number I think. [Here](https://stackoverflow.com/a/45172095/2315280) there is a implementation with checking the size of the TextInput component. – bennygenel Aug 29 '17 at 16:43
0

The numberOfLine props in React Native is just to set initial height of TextInput that can show text in the number of line you set in numberOfLine.

To do what you want you must do some code change in your TexInput maybe this reference link that i found to limit the number of line with the value of numberOfLine as paramater number of line can solve your solution

Maulana Prambadi
  • 1,015
  • 9
  • 7