v2.0.0
Breaking Changes
Index parameter now starts at 0
The index parameter passed to the replacement callback now returns the logical match index (0, 1, 2, 3...) instead of the internal array index (1, 3, 5, 7...).
Before (v1.x):
reactStringReplace('a b c', /(\w)/g, (match, index) => {
console.log(index); // 1, 3, 5
});After (v2.0):
reactStringReplace('a b c', /(\w)/g, (match, index) => {
console.log(index); // 0, 1, 2
});This makes the index more intuitive and useful for React key props.
Migration
If your code relies on the old index values, update your callback logic to expect 0-indexed sequential values.
Full Changelog: v1.2.0...v2.0.0