Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial value #48

Closed
nab39all opened this issue Nov 9, 2021 · 2 comments
Closed

Initial value #48

nab39all opened this issue Nov 9, 2021 · 2 comments
Labels
question Further information is requested

Comments

@nab39all
Copy link

nab39all commented Nov 9, 2021

Can I use initial values for MaskedTextInput?

@nab39all nab39all added the question Further information is requested label Nov 9, 2021
@akinncar
Copy link
Owner

akinncar commented Nov 9, 2021

Yes, you can use defaultValue prop.

<MaskedTextInput
  mask="AAA-9999"
  defaultValue="abc1234"
  onChangeText={(text, rawText) => {
    console.log(text);
    console.log(rawText);
  }}
  style={styles.input}
/>

@SandroDamasceno
Copy link

I tried using defaultValue to load a dynamic initial value from a state, but the value is not displayed. Only an initial value defined as a string is displayed.
In this case, is it possible to use the initial value from the content of a useState state variable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants