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

custom wrapper for elements #429

Closed
mateusarbex opened this issue Nov 18, 2020 · 9 comments
Closed

custom wrapper for elements #429

mateusarbex opened this issue Nov 18, 2020 · 9 comments

Comments

@mateusarbex
Copy link

No description provided.

@jsamr
Copy link
Collaborator

jsamr commented Nov 18, 2020

@mateusarbex Would be very much appreciated if you provided a minimal description. What I understand is basically having the option to render the default renderer in a custom renderer, is that it?

@mateusarbex
Copy link
Author

mateusarbex commented Nov 18, 2020

Sorry for not providing a minimal description but what I want is a way to use the the parsed html element with a custom wrapper renderer. Since the renderer prop happens before the html is parsed, I can't wrapp the result in a wrapper I designed. For example: I want to wrapp the parsed img inside a TouchableOpacity

@jsamr
Copy link
Collaborator

jsamr commented Nov 18, 2020

Would that work out?

const renderers = {
  img: ({ DefaultRenderer, ...props }) => {
    return (
      <TouchableOpacity onPress={/* do stuff */}>
        <DefaultRenderer {...props} />
      </TouchableOpacity>
    );
  },
};

@mateusarbex
Copy link
Author

Yes, it would work perfectly!

@jsamr
Copy link
Collaborator

jsamr commented Nov 18, 2020

@mateusarbex Great. I'll design the next foundry release "renderers" prop with this feature in mind. I'm working on it, expect a first pre-release in a few days ;-)

@mateusarbex
Copy link
Author

Thanks!

@ymj
Copy link

ymj commented Dec 28, 2020

@mateusarbex Would be very much appreciated if you provided a minimal description. What I understand is basically having the option to render the default renderer in a custom renderer, is that it?

That option would be highly appreciated. I would love to have the option to use a custom renderer for elements with certain attributes, and defer to the default rendered if those attributes are not present.

@jsamr
Copy link
Collaborator

jsamr commented Feb 7, 2021

This feature is available in the foundry pre-release (see #430 for instruction on how to try it out). You can use TDefaultRenderer prop for that purpose. Also, note that TDefaultRenderer will always support onPress prop, whether it renders a Text or View. See for example this snippet:

<TDefaultRenderer {...props} onPress={onPress} />

@jsamr
Copy link
Collaborator

jsamr commented Jun 8, 2021

Closing now since the stable beta which fixes this issue has just been released.

@jsamr jsamr closed this as completed Jun 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants