expo / expo/react-native-read-more-text

measure, sometimes, returns different heights

Open
#51 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
580
Forks
111
PR merge metrics
No merged PRs in 30d

Description

I have experienced random bugs with node.measure(). Sometimes, unexpectedly and between re-renders, it returns different sizes for the same node.

I have been thinking that the problem was mine, but nope, styles are always the same, the content to be rendered is always the same, but... magically, measure returns slightly different sizes caused by decimals.

So... maybe you can Math.floor() the text height when calculating.

I am talking about really minimal height differences, for example:

1. On first render: height = 82.389238
2. On second render: height = 82.389133

So maybe,

setShowReadMoreButton(Math.floor(collapsedHeight) < Math.floor(fullHeight));

could help for unexpected behaviors (at least, I am suffering them)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.