replace-react
v0.0.3
Published
ReplaceReact is a library that provides you a way to replace substrings into react components
Downloads
127
Readme
Replace React
ReplaceReact is a library that provides you a way to replace substrings into react components
You have two ways to do it
One: import replaceReact from replace-react
import { replaceReact } from "replace-react";
const MyApp = () => {
return (
<div>
{replaceReact("hello world", /(world)/g, (match, key) => (
<h1 key={key}>{match}</h1>
))}
</div>
);
};
Two: import the extendString file and use it directly with your strings
import "replace-react/extendString";
const MyApp = () => {
return (
<div>
{"hello world".replaceReact(/(world)/g, (match, key) => (
<h1 key={key}>{match}</h1>
))}
</div>
);
};
by Quaantum