webamp/js/components/CharacterString.tsx
2018-09-17 17:04:05 -07:00

22 lines
518 B
TypeScript

import React from "react";
import Character from "./Character";
interface Props {
children: string;
}
class CharacterString extends React.Component<Props> {
shouldComponentUpdate(nextProps: Props) {
return nextProps.children !== this.props.children;
}
render() {
const text = `${this.props.children}` || "";
const chars = text.split("");
return chars.map((character, index) => (
<Character key={index + character}>{character}</Character>
));
}
}
export default CharacterString;