0.0.4 • Published 1 year ago

@ys319/use-replace v0.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

useReplace

React hook for Replace string with component using regexp.

Example

import { MatchRenderer, useReplace } from "@ys319/use-replace";

const Highlight: MatchRenderer = ({ matches: [match] }) => `[${match}]`;

const App = () => {
  const replace = useReplace(/replacer?/ig);

  return (
    <p>
      {replace("React RegExp Replacer!", Highlight)}
      <br />
      {replace("This is very simple replacer hook.", Highlight)}
      <br />
      {replace("Let's RePLaCe it!", Highlight)}
    </p>
  );

  // Output:
  // > React RegExp [Replacer]!
  // > This is very simple [replacer] hook.
  // > Let's [RePLaCe] it!
};
0.0.4

1 year ago

0.0.3

1 year ago

0.0.1

1 year ago