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

[Need help] Any way to reset the chosen value from outside the picker? #44

Open
Mjuk-Biltvatt opened this issue Feb 28, 2017 · 1 comment

Comments

@Mjuk-Biltvatt
Copy link

I'd like to reset the chosen values from outside the picker. When a value is chosen in the modal picker a state is set. When the user then presses a button the values are submitted to my API. When the API then returns an OK status I want to reset the values chosen in the modal picker. This doesn't seem to happen when I pop the route.

Any ideas?

@Mjuk-Biltvatt Mjuk-Biltvatt changed the title [Need help] Any way to reset the chosen values from outside the picker? [Need help] Any way to reset the chosen value from outside the picker? Mar 1, 2017
@FlaviooLima
Copy link

FlaviooLima commented Mar 23, 2017

@Mjuk-Biltvatt I did a dirty hack but for now it solves the problem:
So what i did was, i created a ref in the ModalPicker, and when i'm gonna clear the data from my view, i set the state from ModalPicker and set the state from my view.

It's a dirty hack but for now is better than nothing.

Component:

            <ModalPicker
              ref={(input) => { this.test = input; }}
              data={positionsArray}
              initValue={positionsArray[0].label}
              onChange={(option) => this.setState({selectedPosition:option.key})} />
      clear=()=>{
        this.teste.setState({selected:"---"})
          this.setState({
            selectedPosition:0,
          })
      }

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