Skip to content

Commit 5ada920

Browse files
authored
Merge pull request #82 from mmestiyak/textComponent
added TextComponent props
2 parents 418b455 + 774a624 commit 5ada920

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ npm i react-native-bouncy-checkbox
4444
- `iconStyle`
4545
- `bounceEffect`
4646
- `bounceFriction`
47+
- `textComponent`
4748

4849
## Import
4950

@@ -78,6 +79,7 @@ import BouncyCheckbox from "react-native-bouncy-checkbox";
7879
| Property | Type | Default | Description |
7980
| -------------------- | :-------: | :--------------: | ------------------------------------------------------------------------------------------------------------------------------------------ |
8081
| text | string | undefined | set the checkbox's text |
82+
| textComponent | component | undefined | set the checkbox's text by a React Component |
8183
| onPress | function | null | set your own onPress functionality after the bounce effect, callback receives the next `isChecked` boolean if disableBuiltInState is false |
8284
| disableText | boolean | false | if you want to use checkbox without text, you can enable it |
8385
| size | number | 25 | size of `width` and `height` of the checkbox |

lib/BouncyCheckbox.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export interface IBouncyCheckboxProps {
1818
style?: StyleProp<ViewStyle>;
1919
size?: number;
2020
text?: string;
21+
textComponent?: React.ElementType;
2122
iconStyle?: any;
2223
textStyle?: StyleProp<TextStyle>;
2324
fillColor?: string;
@@ -124,6 +125,7 @@ class BouncyCheckbox extends React.Component<IBouncyCheckboxProps, IState> {
124125
renderCheckboxText = () => {
125126
const {
126127
text,
128+
textComponent,
127129
isChecked,
128130
textStyle,
129131
textContainerStyle,
@@ -132,7 +134,8 @@ class BouncyCheckbox extends React.Component<IBouncyCheckboxProps, IState> {
132134
} = this.props;
133135
const { checked } = this.state;
134136
return (
135-
!disableText && (
137+
!disableText &&
138+
(textComponent || (
136139
<View style={[styles.textContainer, textContainerStyle]}>
137140
<Text
138141
style={[
@@ -143,7 +146,7 @@ class BouncyCheckbox extends React.Component<IBouncyCheckboxProps, IState> {
143146
{text}
144147
</Text>
145148
</View>
146-
)
149+
))
147150
);
148151
};
149152

0 commit comments

Comments
 (0)