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

React Native setState Issue and Warning #18

Open
daltondanis opened this issue Jul 12, 2017 · 0 comments
Open

React Native setState Issue and Warning #18

daltondanis opened this issue Jul 12, 2017 · 0 comments

Comments

@daltondanis
Copy link

First:

Is a prompt unmounted when "visible" parameter is set to false?

if for sure NO

Ignore this issue and close it

If so or maybe

when you setState for the "visible" parameter ("promptVisible") it will cause a:
Warning: Can only update a mounted or mounting component
This setState Warning will happen after opened "promptVisible" to true and you have closed "promptVisible" to false

Example Code:

<Prompt
     title="Enter Amount"
     placeholder=""
     /*defaultValue={this.state.amount}*/
     visible={ this.state.promptVisible } //this is where the warning will happen
     onCancel={ () => this.closePrompt() } //this method contains, console.warn() and this.setState
     onSubmit={
            (value) => this.submitAmount(value) //this method contains, console.warn and this.setState
     } />

Note: submitAmount method setState for state.amount and state.promptVisible

It will check this.state.promptVisible

or check for a change in value

when the prompt is unmounted!

causing the warning.

After major testing and checking all of my other components for setState and state for unmounted and mounted component I drew the conclusion to this react-native-prompts as it's the only component not displayed when "visible" is false.

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

1 participant