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

clicking label text triggers onChange #61

Closed
ghost opened this issue May 11, 2017 · 2 comments
Closed

clicking label text triggers onChange #61

ghost opened this issue May 11, 2017 · 2 comments

Comments

@ghost
Copy link

ghost commented May 11, 2017

Clicking on a the label text triggers onChange for some reason.

Here is my entire checkBox component:

`import React, { Component } from 'react';
import { StyleSheet, View } from 'react-native';
import CheckBox from 'react-native-checkbox';

class PrepositionCheckBox extends React.Component {
componentWillMount() {
if (this.props.transitive === true) {
this.props.handleInitialStateOfActivePrepositionCheckbox(false);
}
}
render() {
return (

<CheckBox
checkboxStyle={styles.prepositionCheckBox}
labelBefore={true}
label={this.props.prepositionCheckBoxLabel}
labelStyle={styles.prepositionCheckBoxLabel}
checked={this.props.prepositionCheckBoxState}
onChange={(prepositionCheckBoxCategory, checked) => this.props.handleCheckBoxClick(this.props.prepositionCheckBoxCategory, this.props.prepositionCheckBoxState)} />

);
}
}

const styles = StyleSheet.create({
prepositionCheckBoxRow: {
flex: 1,
flexDirection: 'row',
justifyContent: 'flex-end',
alignItems: 'flex-start'
},
prepositionCheckBoxLabel: {
height: 25
}
});

export default PrepositionCheckBox;`

@danny-does-stuff
Copy link

danny-does-stuff commented Aug 23, 2017

I believe this is expected behavior. That is standard functionality in web development, and I believe was purposely copied here. If you want to have a label that doesn't trigger onChange simply set label to null and add a <Text> component before or after the <Checkbox> component

@sconxu
Copy link
Owner

sconxu commented Nov 3, 2017

This is the intended behaviour. Please follow @dannyharding10 's suggestion.

@sconxu sconxu closed this as completed Nov 3, 2017
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