https://github.com/iansinnott/react-string-replace
const reactStringReplace = require('react-string-replace')
reactStringReplace('Apt 111, phone number 5555555555.', /(\d+)/g, (match, i) => (
<span key={i} style={{ color: 'red' }}>{match}</span>
));
// =>
// [
// 'Apt ',
// <span style={{ color: 'red' }}>111</span>,
// ', phone number ',
// <span style={{ color: 'red' }}>5555555555</span>,
// '.'
// ]
https://github.com/jgierer12/awesome-babel-macros
//hooks.macro
import { useAutoCallback } from 'hooks.macro';
useAutoCallback(() => {
doSomethingWith(value);
});
//Becomes:
useCallback(() => {
doSomethingWith(value);
}, [doSomethingWith, value]);