Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to hide the "read more" when the content is less than numberOfLines? #35

Open
Lylisa opened this issue Oct 18, 2020 · 3 comments
Open

Comments

@Lylisa
Copy link

Lylisa commented Oct 18, 2020

Sometimes, the content is just a few , I don't want to show the "read more" , I want to show it just when the whole content is more than the numberOfLines, please help me for this ,thank you much more.

@ankitjaiswal1994
Copy link

Did you got the solution ?

@vtsybulin
Copy link

@Lylisa @ankitjaiswal1994 it does that out of the box, only on mount stage tho, no content changes are taken into account for layout recalculations. #36 should fix that.

@cmcodes1
Copy link

cmcodes1 commented Oct 8, 2021

You can use ternary operator:

{
    'yourText'.length > 50
        ?
        <ReadMore
            numberOfLines={1}
            renderTruncatedFooter={(handlePress) => { return <Text onPress={handlePress} style={{ color: 'grey' }}>show more</Text> }}
            renderRevealedFooter={(handlePress) => { return <Text onPress={handlePress} style={{ color: 'grey' }}>show less</Text> }}
        >
            <Text>yourText</Text>
        </ReadMore>
        :
        <Text>yourText</Text>
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants