question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error TextInputMask React Native Paper

See original GitHub issue

Hello, when trying to use the mask in TextInput, it didn’t work presented this problem as shown below.

Anyone who can help, thank you.

Code sample

import { Button, Card, TextInput, TextInputMask } from "react-native-paper"; <TextInput name="telefone" label="(84) 98800-0000" value={this.state.telefone} onChangeText={(text) => this.setState({ telefone: text })} left={<TextInput.Icon name="phone" />} render={(props) => ( <TextInputMask {...props} mask="+[00] [0000] [00000]" /> )} />

What have you tried

However, I tested it at the Snack Expo, and even then it didn’t work as you can see through the link below. https://snack.expo.io/@jacksonm/dfb099

I saw this error here but it didn’t work either. https://github.com/callstack/react-native-paper/issues/1553

Your Environment

My environment is with the following configuration. | react-native-paper “^4.7.2” | | expo sdk ~40.0.0, |

Warning: React.createElement: type is invalid – expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it’s defined in, or you might have mixed up default and named imports.

Check your code at UsuarioFormScreen.js:104. in TextInputFlat (at TextInput.tsx:466)

and

Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it’s defined in, or you might have mixed up default and named imports.

Check the render method of TextInputFlat.

This error is located at: in RCTView (at View.js:34) in View (at TextInputFlat.tsx:320) in RCTView (at View.js:34) in View (at TextInputFlat.tsx:312) in TextInputFlat (at TextInput.tsx:466) in TextInput (created by Context.Consumer) in ThemedComponent (created by withTheme(TextInput)) in withTheme(TextInput) (at UsuarioFormScreen.js:97)…

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
Overzcommented, Apr 19, 2021

Hi @lukewalczak , thank you for feedback.

It worked !! Thank you very much !!

test

5reactions
lukewalczakcommented, Apr 19, 2021

Hey @Overz, within your onChangeText please call also the same method from props to update the component state in order to avoid bug:

      <TextInput
        label="My Label"
        mode="outlined"
        placeholder="Write someting..."
        render={(props) => (
          <RNTextInput
            {...props}
            value={someValue2}
            type="cpf"
            ref={ref2}
            onChangeText={(text) => {
              props.onChangeText?.(text);
              setSomeValue2(text);
            }}
          />
        )}
      />
Read more comments on GitHub >

github_iconTop Results From Across the Web

HelperText · React Native Paper
Helper text is used in conjuction with input elements to provide additional hints for the user.
Read more >
Getting Error on TextInput with TextInputMask in react-native ...
This seems to be a BUG in react-native-text-input-mask library and the code is fixed but pull request is not merged yet so most...
Read more >
Using input masks in React Native - LogRocket Blog
The react-native-text-input-mask library provides input masking features on both Android and iOS platforms. In this tutorial, we will cover:.
Read more >
React Native Text Input - Back4App Blog
The flickering bug may occur when using controlled TextInput (the type of component that receives the prop value directly) and mishandling the user...
Read more >
react native paper issue with TextInput - Expo Snack
react native paper issue with TextInput. No description. Open with Expo Go. Open in editor. Need Expo? Don't have the Expo Go? Download...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found