Open RinNguyens opened 2 years ago
My guess (because I had the same bug) is that you need to use a capturing group in your regex:
let el = reactStringReplace(el, /(\n)/g, (_match, i) => <br key={i} />);
Note the use of /(\n)/g
rather than just /\n/g
.
result : reactStringReplace output not working '/r' in array[2] image above