Cnilton / react-native-floating-label-input

A customizable React Native TextInput with its placeholder always shown. Includes masks, global styles, character count, and a bunch else.
MIT License
293 stars 60 forks source link

autoFocus prop #80

Closed sritharIOS closed 3 years ago

sritharIOS commented 3 years ago

I want to use the autoFocus property and set a default value when the page renders. How to achieve this one?

Cnilton commented 3 years ago

Hi @sritharIOS, I believe you can use the autoFocus as you want because this component extends Textinput props. To set a default value when the page renders, just initialize the state value used on the input with the value you want.

sritharIOS commented 3 years ago
Screen Shot 2021-05-17 at 4 15 39 PM

I tried to set the state but custom label animation is not working. Please refer to the attached screen.

sritharIOS commented 3 years ago
Screen Shot 2021-05-17 at 4 18 45 PM
sritharIOS commented 3 years ago

@Cnilton This issue has been resolved while setting the value during the state initialization. Thanks for the idea. const [text, setText] = useState(defaultValue);