Function component: how to use props as slot like custom component?
See original GitHub issueHi @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:
- Created a year ago
- Comments:27 (17 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.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.