cht8687/react-text-collapse

how to get the accurate 'maxHeight'?

Opened this issue · 3 comments

Hi, I imported your work into my project. It is nice. But it needs the 'maxHeight' otherwise it won't expand. The text shown in this component is undecided length, so I cannot set a fixed value here. Do you have any solution for this problem? Thank you~

@rainshang
I am glad that you like this module.

Are you trying to build dynamic contents? At the moment, this module doesn't have the ability to detect the children's height.

any ideas how to tackle this issue?
@shineli1984 @stevemao @ddvkid

@cht8687
Yes, I'm using this component foe showing the description of a detail page. You know, the content of description varies, depending on the response from the data server. So I cannot get the height for one description text in advance.
I've tried some text measure lib, to calculate the height of a string with a specific font and size. It doesn't work well. Maybe I can go deeper in this way?

@rainshang Yes, that sounds a solution. Welcome to raise a PR for this if you found any better solutions. 👍