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

feat(templates): expose components to template POC #5584

Closed
wants to merge 1 commit into from

Conversation

Haroenv
Copy link
Contributor

@Haroenv Haroenv commented Apr 7, 2023

Summary

Following developit/htm#167, it's possible to expose the components so they look like regular elements, having the advantage that they will show up in devtools, and be able to use hooks.

Result

In templates, you can use the component by its name, instead of the previously already possible "interpolation for the variable"

// before, as a component (still possible) (not documented):
function template(hit, { html, components }) {
  return html`<${components.Snippet} hit=${hit} attribute="description" />`;
}

// before, not as a component (still possible) (documented):
function template(hit, { html, components }) {
  return html`${components.Snippet({ hit, attribute: 'description' })}`;
}

// now, as a component:
function template(hit, { html }) {
  return html`<Snippet hit=${hit} attribute="description" />`;
}

@codesandbox-ci
Copy link

codesandbox-ci bot commented Apr 7, 2023

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 ecc4e70:

Sandbox Source
InstantSearch.js Configuration
react-instantsearch-app Configuration
example-react-instantsearch-hooks-default-theme Configuration
example-vue-instantsearch-default-theme Configuration

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.

1 participant