Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to replace strings with react components

import { replaceReact } from "replace-react";

const MyApp = () => {
  return (
    <div>
      {replaceReact("hello world", /(world)/g, (match, key) => (
        <h1 key={key}>{match}</h1>
      ))}
    </div>
  );
};
Source by quaantum.github.io #
 
PREVIOUS NEXT
Tagged: #replace #strings #react #components
ADD COMMENT
Topic
Name
4+5 =