question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Function component: how to use props as slot like custom component?

See original GitHub issue

Hi @tbranyen, Here is my pseudo-code:

function MyComponent(props) {
  return html`
    <div class="modal-dialog">
        <h2 class="modal-title">${props.title}</h2>
        <div class="modal-footer">${props.footer}</div>
    </div>
  `;
}

innerHTML(document.body, html`<${MyComponent} title="Test Modal Dialog" footer="<button class='btn-close>Close</button><button class='btn-cancel' onClick=${() => this.remove()}>" />`);

The footer props is dynamic. Is it possible without using web-component?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:27 (17 by maintainers)

github_iconTop GitHub Comments

1reaction
tbranyencommented, Mar 29, 2022

Hi @dan-do I have not yet added the createSideEffect method. I will put it in today, I think that will suffice for your needs.

0reactions
tbranyencommented, Apr 3, 2022

image

This regex appears plenty sufficient to chunk out the tags, and then I’m going to use the existing regex to parse out the tagName and attributes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Passing Props to a Component - React Docs
React components use props to communicate with each other. ... But you can pass any props to your own components, such as <Avatar>...
Read more >
How to use Props in React - Robin Wieruch
Everything you need to know about props in React. How to pass props to components, how to set default props, how to know...
Read more >
React render props vs. custom Hooks - LogRocket Blog
React Hooks and render props can co-exist because they solve the same problem of moving state away from your components.
Read more >
A Simple Guide to Component Props in React
In this guide you'll find what are component props in React and how to use them.
Read more >
React component as prop: the right way™️
Exploring how to pass React components as props, why we would want to do it, and what is the best pattern for the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found