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

The clicked radio is not selected #53

Closed
donni106 opened this issue Jul 28, 2017 · 6 comments
Closed

The clicked radio is not selected #53

donni106 opened this issue Jul 28, 2017 · 6 comments

Comments

@donni106
Copy link

When i click through the RadioForm it has a strange behaviour. Only every second click gets active.

2017-07-28 14_29_15

When clicking the same radio twice, it works.
Looks like the created radios are not connected correctly?

react-native-simple-radio-button@^2.5.0-alpha.1:
version "2.6.0"
<RadioForm
  radio_props={radioAnswers}
  initial={10}
  buttonColor={'#444'}
  onPress={(value) => this.setState({ answer: value })}
  style={BasicStyles.radios}
/>
@donni106
Copy link
Author

Found out, that the user interface works correctly, if changing the onPress method to onPress={(value) => console.log(value)}. So something with setting the state is confusing?

@yogipriyo
Copy link

I have the same problem and it is true that the value actually got updated the first time it is clicked. Anyone have solution for this?

@yogipriyo
Copy link

After looking at the SimpleRadioButton.js file and tried several changes, I found that the error will be gone after I disabled the code from line 36 to 40.

// componentWillReceiveProps (newProps) { // if (newProps.initial !== this.state.is_active_index) { // this.setState({ is_active_index: newProps.initial }) // } // },

@donni106
Copy link
Author

donni106 commented Aug 9, 2017

Can you open a Pull Request for this?
Maybe @moschan will have a look then?

yogipriyo added a commit to yogipriyo/react-native-simple-radio-button that referenced this issue Aug 10, 2017
Reason : this issue moschan#53

After some trial and error, I managed to fix the issue by commenting the componentWillReceiveProps. Can you please try take a look and analyze why this issue happen and can be fixed by commenting those part of code?

Thank you.
@yogipriyo
Copy link

Done creating PR

@moschan
Copy link
Owner

moschan commented Aug 13, 2017

Hi, thank you for your report and PR.
I updated new version, please check the latest one.

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

3 participants