I'm implementing a read more read less button in a nextjs app with strapi backend. I try to use a .slice but the text comes from the API through a ReactMarkdown component.
So I get this error :
TypeError : text.slice is not a function
I started with this before I got stopped by the error
const ReadMore = ({ children, maxCharacterCount = 100 }) => { const text = children;
const resultString = text.slice(0, 100);
return (
{resultString} Read more {/* {isTruncated ? "Voir plus" : "Voir moins"} */}
); <ReadMore>
<ReactMarkdown source={item.texte} />
</ReadMore>