Skip to content

Commit 1d4d858

Browse files
author
Sibtain Ali
committed
chore(#67): Changed documentation. Made code more readable.
1 parent 756e30b commit 1d4d858

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ If you have an urgent problem, hire a mentor for a 1:1 live session on Git-Start
2727
Help others in paid 1:1 live sessions to get started.
2828
[![Give paid 1:1 live support.](https://git-start.com/assets/git-start-mentor-banner-medium.svg?sanitize=true)](https://git-start.com/help-request/overview/peacechen%2Freact-native-modal-selector)
2929

30+
## Breaking changes
31+
32+
Version 2.0.0 onwards support multi-select feature. As such, following properties from the versions before have changed.
33+
34+
1) `selectedKey` is now `initSelectedKeys`. It accepts an array of keys.
35+
2) `getSelectedItem` is now `getSelectedItems`. It returns an array of selected items.
3036

3137
## Usage
3238

@@ -181,7 +187,7 @@ Prop | Type | Optional | Default | Description
181187
`customSelector` | node | Yes | undefined | Render a custom node instead of the built-in select box.
182188
`initSelectedKeys` | array<any> | Yes | [] | Key of the items to be initially selected. Should contain only one key if `multiple` is selected as false.
183189
`multiple` | bool | No | false | Adds the ability to select multiple options.
184-
`renderCheckbox` | function | No | (checked, onPress) => {} | Function that returns a checkbox element. Arguments of the function include `checked` state and `onPress` function that gets executed when the element is pressed.
190+
`renderCheckbox` | function | Yes | (checked, onPress) => {} | Function that returns a checkbox element. Arguments of the function include `checked` state and `onPress` function that gets executed when the element is pressed. Required only if multiple option is selected.
185191

186192
### Methods
187193

index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ const defaultProps = {
128128
customSelector: undefined,
129129
initSelectedKeys: [],
130130
multiple: false,
131-
renderCheckbox: undefined,
131+
renderCheckbox: () => {},
132132
};
133133

134134
export default class ModalSelector extends React.Component {
@@ -186,12 +186,14 @@ export default class ModalSelector extends React.Component {
186186
onChange = (item, checked = false) => {
187187
let { selected } = this.state;
188188
const itemKey = this.props.keyExtractor(item);
189-
if (this.props.multiple)
189+
if (this.props.multiple) {
190190
checked
191191
? selected.push(itemKey)
192192
: selected.indexOf(itemKey) >= 0 &&
193193
delete selected[selected.indexOf(itemKey)];
194-
else selected = [itemKey];
194+
} else {
195+
selected = [itemKey];
196+
}
195197
if (
196198
Platform.OS === "android" ||
197199
(Modal.propTypes !== undefined && !Modal.propTypes.onDismiss)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-modal-selector",
3-
"version": "1.1.3",
3+
"version": "2.0.0",
44
"description": "A cross-platform (iOS / Android), selector/picker component for React Native that is highly customizable and supports sections.",
55
"main": "index.js",
66
"typings": "index.d.ts",

0 commit comments

Comments
 (0)