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

fix(render): pass renderer.render to default render function #940

Merged
merged 2 commits into from
Apr 8, 2022

Conversation

sarahdayan
Copy link
Member

This PR fixes a bug when using the renderer option without the render option.

Since #920 you no longer need to pass the render option; instead you can pass a custom render function via the renderer option. This caused a bug with custom VDOM implementations because render wasn't passed to the internal defaultRender function, and fell back on Preact's render.

This PR also cleans up some tests that were never run. We can write them properly in a separate PR.

@codesandbox-ci
Copy link

codesandbox-ci bot commented Apr 8, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 7c2f351:

Sandbox Source
@algolia/autocomplete-example-github-repositories-custom-plugin Configuration
@algolia/autocomplete-example-instantsearch Configuration
algolia/autocomplete Configuration
@algolia/autocomplete-example-preview-panel-in-modal Configuration
@algolia/autocomplete-example-react-renderer Configuration
@algolia/autocomplete-example-starter-algolia Configuration
@algolia/autocomplete-example-starter Configuration
algolia/autocomplete Configuration
algolia/autocomplete Configuration

Copy link
Contributor

@Haroenv Haroenv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

render({ children }, root) {
render(children as ReactElement, root);
},
renderer: { createElement, Fragment, render: render as Render },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is the cast needed? is the type too narrow to accept react's render?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but it's assignable to Render so the cast is valid.

Comment on lines +57 to 58
const defaultRender: AutocompleteRender<any> = ({ children, render }, root) => {
render(children, root);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this here is the actual fix right?

Copy link
Member Author

@sarahdayan sarahdayan Apr 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the rest is just type updates.

Copy link
Member

@dhayab dhayab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the fix!

@sarahdayan sarahdayan merged commit 55f53d1 into next Apr 8, 2022
@sarahdayan sarahdayan deleted the fix/renderer-render branch April 8, 2022 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants