Skip to content

Commit 7fcfd4c

Browse files
committed
Add info about indexing in README
1 parent 72290b8 commit 7fcfd4c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

readme.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ reactStringReplace('whats your name', 'your', (match, i) => (
3434
<span>{match}</span>
3535
));
3636
// => [ 'whats ', <span>your</span>, ' name' ]
37+
38+
39+
// Note that indexing [i] here starts at 1, not 0
40+
// If you need to change this behavior for now try the workaround:
41+
let count = -1;
42+
reactStringReplace("the more the better", "the", (match, i) => (
43+
count ++
44+
<span>{match}</span>
45+
));
3746
```
3847

3948
### More realistic example

0 commit comments

Comments
 (0)