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.

TextInput with nested Text field for styling duplicates letters when typing.

See original GitHub issue

Description

Recently we updated to RN 0.70, and have encountered an issue where having a nested <Text> inside a <TextInput> field causes double typing. Before this worked fine in RN 0.63.

We use this to stylize @mention inputs for a chat feature.

Notes: Adding value={‘’} fixes the issue for iOS, but causes a crash on Android with Cannot specify both value and children..

I managed to get it working on Android by commenting that line out in the RN code base, and patching it, but it causes another issue, where typing on Android “skips” a few letters when typing.

Version

0.70.0

Output of npx react-native info

System: OS: macOS 12.5.1 CPU: (12) x64 Intel® Core™ i7-8850H CPU @ 2.60GHz Memory: 1.82 GB / 16.00 GB Shell: 5.7.1 - /usr/local/bin/zsh Binaries: Node: 16.17.0 - ~/.nvm/versions/node/v16.17.0/bin/node Yarn: 1.22.19 - ~/git/caliber-mobile-app/node_modules/.bin/yarn npm: 8.18.0 - ~/.nvm/versions/node/v16.17.0/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: Not Found SDKs: iOS SDK: Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5 Android SDK: Not Found IDEs: Android Studio: Chipmunk 2021.2.1 Patch 2 Chipmunk 2021.2.1 Patch 2 Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild Languages: Java: 11.0.16 - /Users/abednarek/.sdkman/candidates/java/current/bin/javac npmPackages: @react-native-community/cli: Not Found react: 18.1.0 => 18.1.0 react-native: v0.70.0 => 0.70.0 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Steps to reproduce

  • Use a Text Input with nested <Text> for styling
  • Type in the text field, and notice that the characters are duplicated. 1 set is Styled as per the <Text> component, and the others are styled differently.

Snack, code example, screenshot, or link to a repository

Code Snippet on reproducing this issue. Quite straight forward:

<TextInput
  style={{
    width: 240,
    height: 44,
    backgroundColor: '#ccc',    
  }}
  onChangeText={(text) => {
    setEnteredText(text);
  }}          
  >
  <Text
    style={{
      color: '#F0F'
    }}>
      {enteredText}
  </Text>
</TextInput>

Here’s what it looks like when I type “Hi”: Screen Shot 2022-09-12 at 2 25 20 PM

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:6
  • Comments:7

github_iconTop GitHub Comments

4reactions
HackerM00ncommented, Sep 17, 2022

Faced the same problem after updating RN 0.68.0 to 0.70.1.

Compared TextInput.js and found two lines that break our functionality.

Screenshot 2022-09-17 at 11 51 56

I just commented them and it worked for me. No need to add value={‘’}.

Hope this helps you too.

4reactions
efstathiosntonascommented, Sep 16, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

How do you make just some text, inside an input text field, bold?
Here is one trick. An INPUT field is over a SPAN. With a an example of function that puts the 3 first chars...
Read more >
Rich text element overview - Webflow University
Use a Rich Text Element (RTE) to create long-form content. ... it from the rich text field, style the nested elements, and then...
Read more >
Excel FILTER function with formula examples - Ablebits
See how to filter in Excel dynamically with formulas. Examples to filter duplicates, cells containing certain text, with multiple criteria, ...
Read more >
Input syntax manual - Serpent Wiki
The input file is divided into separate data blocks, denoted as cards. ... The nested data meshes (type 9) take the coordinates' level...
Read more >
Input Components - React-admin - Marmelab
Tip: Use the sx prop rather than className to style the component. defaultValue. Value of the input if the record has no value...
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