Skip to content

Commit bef1b60

Browse files
committed
Added details about array notation in README file.
1 parent 383b0b0 commit bef1b60

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- Package size is: 1.42KB (0.7KB gzipped!).
1212
- Supports all `<input />`s, checkboxes and `<select />`.
1313
- Supports `<select multiple />`.
14+
- Supports checkboxes with same via [array notation](#array-notation).
1415
- Multiple bundles: [CJS, ESM and UMD](dist).
1516

1617
## Installation
@@ -85,17 +86,19 @@ By default, **react-input-handler** handles checkbox as boolean value. Sometimes
8586
**Before:**
8687
8788
```js
88-
<input type="checkbox" name="numbers" value="1" onChange={ReactInputHandler.bind(this)} />
89-
<input type="checkbox" name="numbers" value="2" onChange={ReactInputHandler.bind(this)} />
90-
<input type="checkbox" name="numbers" value="3" onChange={ReactInputHandler.bind(this)} />
89+
<input type="checkbox" name="one" value="1" onChange={this.inputHandler} checked />
90+
<input type="checkbox" name="two" value="2" onChange={this.inputHandler} />
91+
<input type="checkbox" name="three" value="3" onChange={this.inputHandler} checked />
92+
// state: { one: true, two: false, three: true }
9193
```
9294
9395
**After:**
9496
9597
```js
96-
<input type="checkbox" name="numbers[]" value="1" onChange={ReactInputHandler.bind(this)} />
97-
<input type="checkbox" name="numbers[]" value="2" onChange={ReactInputHandler.bind(this)} />
98-
<input type="checkbox" name="numbers[]" value="3" onChange={ReactInputHandler.bind(this)} />
98+
<input type="checkbox" name="numbers[]" value="1" onChange={this.inputHandler} checked />
99+
<input type="checkbox" name="numbers[]" value="2" onChange={this.inputHandler} />
100+
<input type="checkbox" name="numbers[]" value="3" onChange={this.inputHandler} checked />
101+
// state: { numbers: ["1", "3"] }
99102
```
100103
101104
## Development

0 commit comments

Comments
 (0)