Skip to content

Component type support for 'icon' prop and bugfix and update Readme #21

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions ItemCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,14 @@ class ItemCell extends React.Component {
}

_renderIcon () {
if (this.props.icon) {
if (React.isValidElement(this.props.icon)) {
return (
<View style={styles.iconContainer}>
{this.props.icon}
</View>
)
}
else if (this.props.icon) {
return (
<View style={styles.iconContainer}>
<Image
Expand Down Expand Up @@ -112,12 +119,12 @@ ItemCell.propTypes = {
...TouchableHighlight.propTypes,
backgroundColor: PropTypes.string,
subtitle: PropTypes.string,
children: PropTypes.string.isRequired,
value: PropTypes.string,
showDisclosureIndicator: PropTypes.bool,
textStyle: Text.propTypes.style,
chevronColor: PropTypes.string,
icon: PropTypes.oneOfType([
PropTypes.element,
PropTypes.number,
PropTypes.shape({
uri: PropTypes.string,
Expand Down
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,22 @@ A React Native default iOS item cell. The cell grows with the inner text.

## Install

RN>=0.18 is required for `1.4.x`. Install the package:
RN>=0.18 is required for `1.4.x`.

### 1. Install the package:

#### option: yarn
```bash
$ yarn add react-native-item-cell
```

#### option: npm
```bash
$ npm install react-native-item-cell --save
```

### 2. Install the dependence:

Install ``FontAwesome`` from the awesome Joel Oblador's ``react-native-vector-icons``: https://github.com/oblador/react-native-vector-icons#installation


Expand All @@ -30,8 +40,7 @@ Install ``FontAwesome`` from the awesome Joel Oblador's ``react-native-vector-ic
| Prop | Type | Description |
|------|------|-------------|
|``showDisclosureIndicator`` | ``bool`` | Shows a small arrow at the right side of the cell. |
|``icon`` | ``{uri: string}`` object or ``require()`` | URI to render left icon with an URL for the image source or ``require`` for a local image source. |
|``children`` | ``string`` | The inner text to render. |
|``icon`` | React component or ``{uri: string}`` object or ``require()`` | React component or URI to render left icon with an URL for the image source or ``require`` for a local image source. |
| `subtitle` | `string` | An optional subtitle to render below the `children`. |
| `value` | `string` | An optional value to display instead of the disclosure indicator. |
| `backgroundColor` | `string` | The color code of the cell background color. |
Expand Down