Closed UmarFKhawaja closed 2 years ago
Hi @UmarFKhawaja , thanks for putting this bug here. I will try to reproduce this.
For multiple rendering, this component actually renders the component multiple times (hidden behind) to calculate the text width and lines. Also the see more and see less texts are rendered separately using the custom component.
Thanks @fawaz-ahmed. When I say rendered twice, I mean that it shows up twice on screen, not rendered in the sense that the render loop is run twice.
I see. Can you share a screenshot ?
From: Umar Farooq Khawaja @.> Sent: Friday, May 20, 2022 1:59:51 PM To: fawaz-ahmed/react-native-read-more @.> Cc: Fawaz Ahmed @.>; Mention @.> Subject: Re: [fawaz-ahmed/react-native-read-more] CustomTextComponent issues (Issue #65)
Thanks @fawaz-ahmedhttps://github.com/fawaz-ahmed. When I say rendered twice, I mean that it shows up twice on screen, not rendered in the sense that the render loop is run twice.
— Reply to this email directly, view it on GitHubhttps://github.com/fawaz-ahmed/react-native-read-more/issues/65#issuecomment-1132656053, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AEJEVIEZPNXUICPIXXHO5WDVK5IAPANCNFSM5WJ7ZKLQ. You are receiving this because you were mentioned.Message ID: @.***>
Apologies about the delay. Here's a screenshot.
The first two paragraphs in the screenshot above are being rendered via the ReadMore component, starting from "Fusce" and ending at "aliquet".
@UmarFKhawaja I debugged a bit. The problem is the Markdown component is not passing additional props like onLayout or onTextLayout down to the children component. ReadMore component will not work without it, since it needs those callback props to measure the text width and lines.
Since the issue is with Md component not passing down all props to child components, I will de-scope this issue and close this bug. @UmarFKhawaja if you have any update, you may re-open.
PS: You can resolve this issue with forking the original Md github repo and update it to pass down all props down to the lowest Text component: index -> AstRenderer -> rules based components
I am trying to render some Markdown formatted text in a ReadMore. For this to work, I have to send the
Markdown
component toReadMore
in thecustomTextComponent
prop.When I do the following, it produces an error:
undefined is not an object (evaluating 'node.children.map')
This seems to be an error from within the
Markdown
component.The same thing happens if I provide a simple functional component wrapping the
Markdown
component, as follows:If I wrap the
Markdown
component with an inline functional component, as follows, it renders, but twice, one after the other.Any help I can get on this will be much appreciated.