Skip to content

Commit

Permalink
Readme update for character offset
Browse files Browse the repository at this point in the history
  • Loading branch information
pejrak committed Nov 22, 2016
1 parent 716f9d8 commit a388a8f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ reactStringReplace('hey hey you', /(hey)/g, () => <span>hey</span>);

Type: `function`

The replacer function to run each time `match` is found. This function will be patched the matching string and an index which can be used for adding keys to replacement components if necessary.
The replacer function to run each time `match` is found. This function will be patched the matching string and an `index` which can be used for adding keys to replacement components if necessary. Character `offset` identifies the position of match start in the provided text.

```js
const func = (match, index) => <span key={index}>{match}</span>;
const func = (match, index, offset) => <span key={index}>{match}</span>;
reactStringReplace('hey hey you', /(hey)/g, func);
```

Expand Down

0 comments on commit a388a8f

Please sign in to comment.