我已经对文本进行了拆分。现在我想将它进一步拆分为单个字母/字符。此外,我想将拆分过程扩展到内容内部的一组数组。
下面是我的反应代码:
import React from "react";
import "./styles.css";
import content from "./content";
// Splitting Texts
const SplitText = React.memo(({ str }) => {
return (
<div>
{str.split(" ").map((item, index) => {
return <div key={index}>{item}</div>;
})}
</div>
);
});
// Main App
export default function App() {
return (
<div className="App">
<h1>
<SplitText str={"Lucie Bachman"} />
</h1>
<h2>
<SplitText str={"Hey, this is my first post on StackOverflow!"} />
</h2>
</div>
);
}