Here is my component, I want to do this: if the text has 50 letters show them and if it has more than 50 show the text and ...
const Post: React.FC = ({
text
}) => {
return ( <p> {text} </p> );
};
CodePudding user response:
You can achieve that using slice(starting value, ending value)
<p> {text ? .length >= 50 ? text ? .slice(0, 50) "..." : text} </p>