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.

React Native - Using normalize along with a wrapped TextInput causes input characters to appear multiple times

See original GitHub issue

This could be because of wrong usage of the library, but I’m stuck on this.

I have the following snippet where I’m using the following lib versions: react 15.3.2 react-native 0.37.0 redux 3.6.0 react-redux 4.4.6 redux-form 6.2.1

import { TextInput } from 'react-native';

function renderInput(props) {
  const { input } = props;
  return (
    <TextInput width={200} {...input} />
  );
}

function toUpper(value) {
  return value && value.toUpperCase();
}

function AndroidCmp(props) {
    return (
      <View>
        <Field name="firstName" component={renderInput} normalize={toUpper}/>
      </View>
    );
}

export default reduxForm({
  form: 'Whyyy',
})(AndroidCmp);

When I type in text, it turns to uppercase, but duplicate characters to appear. eg. If want to type ‘help’, here’s what shows up:

typed so far: ‘h’ -> H

typed so far: ‘he’ -> HHE

typed so far: ‘hel’ -> HHEHHEL

…and so on.

Sometimes the expected single character appears (but on next keypress, more duplicate stuff appears).

Without normalize, the duplication issue doesn’t happen (of course, no normalization happens).

I’ve tried an equivalent example using React web - using custom component that simply wraps an input, but did not face issues. This could imply some usage issue with react-native’s TextInput but I’d appreciate help on solving this - as I think I’ve followed the docs on how to handle a custom input.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:2
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
ValentinBlokhincommented, Nov 14, 2017

I have the same issue on android

0reactions
soh335commented, Sep 11, 2020
Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native - Using normalize along with a wrapped ... - GitHub
React Native - Using normalize along with a wrapped TextInput causes input characters to appear multiple times #2252.
Read more >
TextInput - React Native
A foundational component for inputting text into the app via a keyboard. Props provide configurability for several features, ...
Read more >
How would I grow <TextInput> height upon text wrapping?
My answer is to use onContentSizeChange and numberOfLines props in ... This actually doesn't increase the text input height when the content grows,...
Read more >
How To Avoid Performance Pitfalls in React with memo ...
The itemize function is going to loop over every character several times and will be very slow as the text size increases.
Read more >
Examples - Final Form Docs
Uses the built-in React inputs: input , select , and textarea to build a form with no ... how to display errors next...
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