Skip to content

Instantly share code, notes, and snippets.

@mfix22
Last active April 2, 2019 20:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mfix22/82d742f4efad9757cc826d20f2a5e5af to your computer and use it in GitHub Desktop.
Save mfix22/82d742f4efad9757cc826d20f2a5e5af to your computer and use it in GitHub Desktop.
Replace string component
export function replaceWithComponent(regex, mapping, s) {
const parts = s.split(regex);
for (let i = 1; i < parts.length; i += 2) {
parts[i] = mapping(parts[i]);
}
return <Fragment>{parts}</Fragment>
}
{"paddingVertical":"56px","paddingHorizontal":"56px","marginVertical":"45px","marginHorizontal":"45px","backgroundImage":null,"backgroundImageSelection":null,"backgroundMode":"color","backgroundColor":"green","dropShadow":true,"dropShadowOffsetY":"20px","dropShadowBlurRadius":"68px","theme":"seti","windowTheme":"none","language":"javascript","fontFamily":"Hack","fontSize":"14px","lineHeight":"133%","windowControls":true,"widthAdjustment":true,"lineNumbers":false,"exportSize":"2x","watermark":false,"squaredImage":false,"preset":null,"loading":false}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment