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

Short lived TextView causing error "Trying to set local data for view with unknown tag: 4" on Android in RN 0.50.3 #16821

Closed
meros opened this issue Nov 14, 2017 · 31 comments
Labels
Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.

Comments

@meros
Copy link

meros commented Nov 14, 2017

Is this a bug report?

Yes

Have you read the Contributing Guidelines?

Yes

Environment

Environment:
OS: macOS Sierra 10.12.6
Node: 8.3.0
Yarn: 1.1.0
npm: 5.4.2
Watchman: 4.9.0
Xcode: Xcode 9.1 Build version 9B55
Android Studio: 3.0 AI-171.4408382

Packages: (wanted => installed)
react: 16.0.0 => 16.0.0
react-native: 0.50.3 => 0.50.3

Steps to Reproduce

Create a view with a TextInput, make sure this view is showing when app is loaded but hidden quickly after (due to asynchronous event).
2.
Let this app load in the android emulator
3.
Once in a while you get error "Trying to set local data for view with unknown tag: 4"

Expected Behavior

I expect removing the TextInput shortly after app loading to work every time on Android without any errors

Actual Behavior

There seems to be a race condition when starting up the app causing the error
screenshot_1510671656

Reproducible Demo

Run this demo in the simulator. I have not been able to reproduce this on a device

https://github.com/FranklyDev/react-native-0_50_3-android-bug-testcase

@meros
Copy link
Author

meros commented Nov 14, 2017

Please note that I can reproduce the error only maybe once/10 reloads or so.

@matthamil
Copy link

matthamil commented Nov 14, 2017

I'm also experiencing this. I get it every time I render a TextInput and immediately hide or transition to another screen.

@wangghon
Copy link

There is a change in 0.51.0-rc.1, no exception anymore.
f2c6877#diff-e40bcf61507821200dcf1f573eb717e3

@matthamil
Copy link

That change isn't published to npm yet is it? Is the solution to compile RN from source? @wangghon

@wangghon
Copy link

wangghon commented Nov 14, 2017

0.51.0-rc.1 is not published to npm yet. I think it would be soon. need to build react-native from source to make the change take effects

@arashmilani
Copy link

Is there any other workaround other than compiling RN from source

@yaohongkok
Copy link

yaohongkok commented Nov 20, 2017

@wangghon I am wondering when will '0.51.0' be available officially on NPM?

@wangghon
Copy link

@yaohongkok I am waiting for the release as well. Hope it can be released soon.

@phu-tang
Copy link

I faced this problem when upgrade to react-native 0.50 :( but a little bit ( ... tag: 20) not sure it's relative but stacktrace is the same

@GitHubTracey
Copy link

working with RN 0.50.4 and experiencing the same issue.

@ociata
Copy link

ociata commented Dec 2, 2017

Any workaround at least until it is merged?

@jerameel
Copy link

jerameel commented Dec 3, 2017

Having this issue on 50.4 using windows, error occured on both emulator and actual device

@arashmilani
Copy link

I'm developing a redux-react-native app and as a workaround I just delay the rendering by some milliseconds between two states changes using a simple setTimeout while dispatching the next action.

@jerameel
Copy link

jerameel commented Dec 3, 2017

how would you know where to add the delay? I'm on redux now

@arashmilani
Copy link

in my case it just happens in some particular action and specific scenario
so I just delay dispatching that specific action.

@Tennen
Copy link

Tennen commented Dec 3, 2017

I prevent updating the component after the action (in my case submit action) which may cause the component unmount

@jerameel
Copy link

jerameel commented Dec 3, 2017

setTimeout actually does the thing for me, so the issue is with the initial component immedietly invoking an action that triggers conditional rendering. Kudos to arasmilani for pointing that out

@ociata
Copy link

ociata commented Dec 3, 2017

If not using redux, how we could fix it? I tried conditionally rendering TextInput with timeout, without success - once inserting the TextInput(after 3 sec) it again fails:

render() {

    let render = this.state.shouldRender ?
    <TextInput
      style={styles.search_text}
      placeholder="Type here to search!"
      onChangeText={(text) => this._onTextChanged(text)}
    /> :
    <View/>

    return <View style={styles.main_view}>
       <View style={styles.search_holder}>
         {render}
       </View>
       <View style={{flex:1}}>
         <ListView
           dataSource={this.state.dataSource}
           renderRow={this._renderListRow.bind(this)}/>
       </View>
     </View>
  }

  componentDidMount(){
    setTimeout(() => {

      this.setState({
        shouldRender: true
      })

    }, 3000)

  }

More importantly - I'm not hiding or manipulating the TextView in any manner. The exception is thrown 100% on Android 4.4 real device.

@GitHubTracey
Copy link

GitHubTracey commented Dec 7, 2017

This change is in the latest release!
https://github.com/facebook/react-native/releases/tag/v0.51.0

@munkhorgil
Copy link

I just got this error in Android react-native 0.50.0, Still no solution?

@GitHubTracey
Copy link

@munkhorgil - I am at the latest release, 0.51.0, and no longer have this issue. The fix mentioned above has been included in the release. Happy Coding!

@munkhorgil
Copy link

@GitHubTracey Thanks for notify!

@munkhorgil
Copy link

I updated to latest release as 0.51, and no longer crash on device. But it re-renders current component and logs in Android Studio as ReactNative: Attempt to set local data for view with unknown tag my textinput as follows

<TextInput
  ref={name}
  blurOnSubmit={false}
  autoCorrect={false}
  style={styles.inputStyle}
  underlineColorAndroid="transparent"
  onSubmitEditing={() =>
  this.updateField({
     ref: ref, 
     key: key ? key : name, 
     name: name,
      label: label
  })
}
  onChangeText={value => this.setState({[name]: value})}
 value={this.state[name]}
/>

milciunas added a commit to milciunas/mif-health-redux-saga that referenced this issue Dec 27, 2017
@stale
Copy link

stale bot commented Feb 16, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. If you think this issue should definitely remain open, please let us know why. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Feb 16, 2018
@challme28
Copy link

At react native 0.53 it no longer shows me the Trying to set local data for view with unknown tag: X message

@stale stale bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Feb 19, 2018
@react-native-bot
Copy link
Collaborator

Thanks for posting this! It looks like you may not be using the latest version of React Native, v0.53.0, released on January 2018. Can you make sure this issue can still be reproduced in the latest version?

I am going to close this, but please feel free to open a new issue if you are able to confirm that this is still a problem in v0.53.0 or newer.

How to ContributeWhat to Expect from Maintainers

@react-native-bot react-native-bot added Ran Commands One of our bots successfully processed a command. Stale There has been a lack of activity on this issue and it may be closed soon. labels Feb 24, 2018
@stale stale bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Feb 24, 2018
@KarthikBaleneni
Copy link

KarthikBaleneni commented Mar 22, 2018

In RN 0.53 . The issue still exists. Happens one in case of 10 attempts.

@GregorHorvatH
Copy link

"react-native": "0.54.4" - fixed

@joshuapinter
Copy link
Contributor

✅ Confirmed. Fixed in React Native 0.54.4.

@ashishalgo
Copy link

we are using react version 0.50.4 version and facing the same issue and we can not update the react version because we are using Salesforce sdk in which 0.50.4 react version is used.

Is there any resolution for same version to fix this issue?

@tal987
Copy link

tal987 commented Feb 11, 2019

@ashishalgo Did you find solution?

@facebook facebook locked as resolved and limited conversation to collaborators Feb 24, 2019
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Feb 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests