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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom renderer for reference editors #283

Closed
stefanjudis opened this issue Jun 30, 2020 · 0 comments 路 Fixed by #298
Closed

Allow custom renderer for reference editors #283

stefanjudis opened this issue Jun 30, 2020 · 0 comments 路 Fixed by #298
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed planned

Comments

@stefanjudis
Copy link

Hello everybody. 馃憢

When using the reference and asset editors I'd love to have a way to control how the selected entry/asset is rendered in the Contentful UI.

Currently, the usage of these reference editors looks like below:

<SingleEntryReferenceEditor viewType="card" sdk={sdk} />

Unfortunately, there is no easy way to customize the rendering of selected entries other then re-implementing the whole reference component. I'd like to propose a way to make that possible.

Add a render prop

With a render prop developers could control how the entry would be rendered after it's selected.

<SingleEntryReferenceEditor viewType="card" sdk={sdk} renderEntry={(entry) => <h1>entry.fields.title</h1>}/>

In the above example, selected entries would only be rendered with an h1 element.

Pass down a component

The reference editors could accept an optional component to render the entry.

<ReferenceEditor customComponents={{ item: MyItem }} />

In the above example, selected entries would render as MyItem component.


Looking forward to your thoughts. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed planned
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants