From 6dbb5455a1a3ee9a1c6bef21ef170ad342824d20 Mon Sep 17 00:00:00 2001 From: Erdem ILDIZ Date: Thu, 28 Feb 2019 16:08:48 +0300 Subject: [PATCH] Added component props for label --- README.md | 6 +++--- lib/SimpleRadioButton.js | 40 ++++++++++++++++++++++++---------------- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 8f352da..52a90c0 100644 --- a/README.md +++ b/README.md @@ -28,8 +28,8 @@ import RadioForm, {RadioButton, RadioButtonInput, RadioButtonLabel} from 'react- var radio_props = [ - {label: 'param1', value: 0 }, - {label: 'param2', value: 1 } + {label: 'param1' || , value: 0 }, + {label: 'param2' || , value: 1 } ]; var RadioButtonProject = React.createClass({ @@ -113,7 +113,7 @@ Pro /> })} - + ``` diff --git a/lib/SimpleRadioButton.js b/lib/SimpleRadioButton.js index ebc0fd2..5524069 100644 --- a/lib/SimpleRadioButton.js +++ b/lib/SimpleRadioButton.js @@ -254,29 +254,37 @@ export class RadioButtonLabel extends React.Component { buttonColor: '#2196f3', } } - render () { + render() { + const { label } = this.props.obj; + return ( { - if (!this.props.disabled) { - this.props.onPress( this.props.obj.value, this.props.index)} - } - }> - - {this.props.obj.label} + if (!this.props.disabled) { + this.props.onPress(this.props.obj.value, this.props.index); + } + }} + > + + {typeof label === 'object' ? ( + label + ) : ( + + {label} + + )} - ) + ); } }