react-native icon indicating copy to clipboard operation
react-native copied to clipboard

[TextInput] Error setting property 'text' of RCTTextField with tag #144: Native TextInput(Hdsgdh) is 4 events ahead of JS - try to make your JS faster.

Open rclai opened this issue 10 years ago • 43 comments

This error happens when you type extremely fast. The more components you have alongside it, the more likely that this will happen.

<TextInput value={this.state.value} onChangeText={value => this.setState({ value })} />

And if you hit submit IMMEDIATELY after typing, the value won't be set and the input may just be blank.

In order for the value to actually be there, you have to wait just a little bit, then you can hit enter and the value will stay.

This is on iOS.

rclai avatar Dec 17 '15 15:12 rclai

I only experience this issue when I have remote debug live reload hot reload all turned on... If I turn them off, I no longer experience the issue.

crobinson42 avatar Oct 27 '16 20:10 crobinson42

Here's a repo to demonstrate the issue:

Bare bones ReactNative 0.33, redux, & react-redux example on a simple login form (only 1 component)

react-native-issue-808

crobinson42 avatar Oct 27 '16 22:10 crobinson42

Im also seeing this issue, ONLY when live reload and debug remotely are both on. Im currently using RN version 0.37.0 (+ redux / react-redux)

ajonno avatar Nov 20 '16 22:11 ajonno

+1

perrosnk avatar Nov 24 '16 10:11 perrosnk

+1

Update: Can confirm what others have said. If I stop Debugging JS Remotely, the simulator speeds up dramatically and I no longer get the error. If I restart Debugging JS remotely, and the simulator slows again, I can fix it by closing then restarting the simulator itself.

avogel3 avatar Nov 28 '16 05:11 avogel3

#10559

sarovin avatar Nov 28 '16 08:11 sarovin

I fixed the problem by doing:

  1. Stop Remote JS Debugging and Disable Hot reloading
  2. Close Chrome window where the debugging is running
  3. Open a new Chrome window (not just new tab)
  4. Start Remote JS Debugging and Enable Hot reloading

I don't know what causes the problem, but in my case it appears when my mac resumes from sleep, with the simulator running.

perrosnk avatar Nov 28 '16 14:11 perrosnk

the last few comments seems to associate with the performance of our simulator or mobile,I think it is the reason too.

Choicelin avatar Mar 14 '17 08:03 Choicelin

The problem is still there after all this time. Also what helped is close remote debugging

pitops avatar Mar 25 '17 23:03 pitops

I don't think trying to make your views faster, stopping debugging, etc. are real answers. I am working on an app that uses external barcode scanners and the scanner inputs text extremely fast, of which, I doubt any amount of optimization would help fix my issue. I even have this issue in release mode with barcode scanners. Why can it not just update in a delayed manner instead of just ignoring the input?

JasonHenson avatar Apr 21 '17 13:04 JasonHenson

@brentvatne I am still having this issue (so are many others in this thread) Is there a solution to this similar to what @JasonHenson suggested?

MovingGifts avatar May 28 '17 18:05 MovingGifts

cc @sahrens who worked on this initially

brentvatne avatar May 31 '17 15:05 brentvatne

It's definitely the live reload and remote debug in my case. I tested it with the performance monitor on a text input while typing as fast as my little piggies could handle, my RAM moved from:

150MB to roughly 162MP when off. 150MB to a whopping 193MB when live reload and remote debug where on

@JasonHenson You might want to look into debounce and throttle. It's saved me a few times before.

@crobinson42 Thanks a million for that one.

PaulAndreRada avatar Jul 16 '17 02:07 PaulAndreRada

Hi all. I had the same problem, but I founded solution that works for me. The error is because we have a lot of setState in queue. So my solution is:

<TextInput
    onChangeText={text => {
        clearTimeout(this.textTimeout);
        this.textTimeout = setTimeout(()=>this.setState({phone: text}), 100);
    }}
/>

I define Timeout with 100 milliseconds delay (or you can pick any else, try to experiment with it), and on Each next call of "onChangeText" function I clear this timeout and define it again. So if you will type very quick, only your timeout will update, and after 100 milliseconds from your last type setState will update.

kravchuck-den avatar Jul 22 '17 21:07 kravchuck-den

Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally!

If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:

  • Does the issue still reproduce on the latest release candidate? Post a comment with the version you tested.
  • If so, is there any information missing from the bug report? Post a comment with all the information required by the issue template.
  • Is there a pull request that addresses this issue? Post a comment with the PR number so we can follow up.

If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution.

pull-bot avatar Oct 09 '17 17:10 pull-bot

same issues

minhphung210 avatar Jan 31 '18 03:01 minhphung210

I still continue to face this issue. I have a need to enable or disable a button based on if text input being empty or not. AS @kravchuck-den pointed out this issue does not occur if i remove the setState. What is good way to handle view changes that are dependent on the text being empty or not ?

jayasimhaprasad avatar Feb 16 '18 04:02 jayasimhaprasad

My requirement was to disable the button only when the text was empty. I put an if condition to call setState only of this condition turned true and it solved my problem.

jayasimhaprasad avatar Feb 16 '18 05:02 jayasimhaprasad

+1 Same issues. Debugging, Live Reload and Hot Reload Disabled.

juliancorrea avatar Mar 10 '18 20:03 juliancorrea

+1 Same issues. Debugging, Live Reload and Hot Reload Disabled.

yuyao110120 avatar Mar 26 '18 09:03 yuyao110120