react-native-read-more icon indicating copy to clipboard operation
react-native-read-more copied to clipboard

Handle Read More/ Read Less from outside.

Open saad9624-tribalScale opened this issue 2 years ago • 8 comments

Is there any prop available to handle read more / read less from outside. like on button press or something.

saad9624-tribalScale avatar Apr 14 '22 11:04 saad9624-tribalScale

@saad9624-tribalScale you can use the onExpand and onCollapse callback props

fawaz-ahmed avatar Apr 14 '22 14:04 fawaz-ahmed

"optional callback executed when expanded"

I didnt find any option to call this function from outside of ReadMore component. It's just executing when expanded.

saad9624-tribalScale avatar Apr 15 '22 06:04 saad9624-tribalScale

@saad9624-tribalScale none of the methods can be called from outside. Can you explain what is the use case that you're trying to achieve ?

fawaz-ahmed avatar Apr 15 '22 06:04 fawaz-ahmed

I am trying to expand and collapse from onPress event of custom button. Is it doable?

saad9624-tribalScale avatar Apr 15 '22 06:04 saad9624-tribalScale

@saad9624-tribalScale at the moment its not supported

fawaz-ahmed avatar Apr 15 '22 06:04 fawaz-ahmed

I am trying to do this externally because customComponent is not very customizable.

saad9624-tribalScale avatar Apr 15 '22 07:04 saad9624-tribalScale

@saad9624-tribalScale in this file https://github.com/fawaz-ahmed/react-native-read-more/blob/master/example/src/ReadMore.js line 182 The toggle method, you need to call this from outside.

Pass a ref to ReadMore and try calling this method.

Otherwise you can raise a PR, I can merge it.

fawaz-ahmed avatar Apr 15 '22 07:04 fawaz-ahmed

Sure, Thanks.

saad9624-tribalScale avatar Apr 15 '22 07:04 saad9624-tribalScale

@fawaz-ahmed I had difficulties passing a ref, so I created a pr which adds a collapsed prop (https://github.com/fawaz-ahmed/react-native-read-more/pull/70). Hope this could solve the problem.

rawroland avatar Nov 09 '22 20:11 rawroland