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

Redirection inside onFail results in warning about setting State on an unmounted component #54

Closed
tkulpa opened this issue Nov 26, 2018 · 4 comments

Comments

@tkulpa
Copy link

tkulpa commented Nov 26, 2018

https://github.com/fnzc/react-native-pincode/blob/master/src/PinCodeEnter.tsx#L143

Maybe this code could be moved at very end so it will be safe to unmount component on fails and this would also allow for user to manage pinAttemptsAsyncStorageName property in AsyncStorage on thier own

@jeremy-farnault
Copy link
Contributor

Moving this at the end doesn't fix the warning.
Putting a delay in the onFail removes it so I'll keep on investigating to find what is updating the component after the onFail.

      <View style={styles.container}>
        {this.state.ok && <PINCode status={'enter'} timeLocked={5000} onFail={async () => {
          await delay(2000)
          this.setState({ok: false})
        }}/>}
      </View>

@jeremy-farnault
Copy link
Contributor

So it's because of the 'shake' animation when the user fails. It's you don't wait ~1500 ms, you get the warning.
I don't know if you need the animation or not.
I could put a 1500ms delay before firing the onFail prop, or I could remove the animation based on a new property...or something else I can't think of :p

What do you think?

Cheers,
Jeremy

@tkulpa
Copy link
Author

tkulpa commented Nov 28, 2018

It think 1500ms delay will be best and straight forward solution for this :)

@jeremy-farnault
Copy link
Contributor

Fixed in the new version :).

Cheers,
Jeremy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants