I have written the code to make "Read more" functionality in ".tsx" file for my project. The code is:
const ReadMore = ({ children }) => {
const text = children;
const [isReadMore, setIsReadMore] = useState(true);
const toggleReadMore = () => {
setIsReadMore(!isReadMore);
};
return (
<ResponsiveHeading.P className={classes.lighterFont}>
{isReadMore ? text.slice(0, 120) : text}
<span onClick={toggleReadMore} className={classes.readMoreLink}>
{isReadMore ? 'Read more' : 'Show less'}
</span>
</ResponsiveHeading.P>
);
};
Now, I am getting this error for the "children" prop in first line of code I showed above.Error is:
Binding element 'children' implicitly has an 'any' type.ts
How do I fix this?