How could I check how many lines a rendered text takes, no matter if it's displayed on a large or small screen?
On the below component I want to show the anchor element only if the text has 3 lines.
import React from 'react';
type contentProps = {
content: string,
};
function subString(string: string): string {
return string.substring(0, string.length / 2);
}
export const Content = ({ content }: contentProps) =>
content ? (
<p className="content">
{subString(content)}
<a href="#">See More</a>
</p>
) : null;
What should be the flow ? First i need to render the component Second check if it takes 3 lines and after this change the state ?