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.

Dynamically added root components

See original GitHub issue

Summary

Support rendering components dynamically after a blazor server or blazor webassembly application has started.

Motivation and goals

We want to improve the way you can add interactivity to an asp.net Core MVC or razor pages application by enabling components to be rendered directly from within JavaScript/HTML intead of just when the app has started.

This enables scenarios where an MVC application that is using JavaScript to add interactivity when an element is added to the dom, can instead leverage Blazor to implement the functionality associated with that component, enabling combining Blazor with existing JavaScript code in a mix and match fashion.

In scope

  • Provide a set of APIs available through JavaScript that enable application authors to create new component instances on Blazor Webassembly and Blazor server.
  • Enable passing parameters to a component from JavaScript

Out of scope

  • Children content within a component. This is more complicated and would like want to take it out of the inital version and add support for it based on feedback.

Risks / unknowns

For server side Blazor there are security implications to this feature that we need to account for, like a limit on the number of components that can be rendered at any time or the list of components that can be rendered as well as their parameters.

Examples

Blazor.renderComponent(element, { componentName: "ShoppingCart" }, parameters: { shoppingCartId: "asdf" });
<shoppint-cart shopping-cart-id="asdf" />

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:29
  • Comments:20 (8 by maintainers)

github_iconTop GitHub Comments

6reactions
RChrisCoblecommented, Jun 23, 2021

Really hope this behavior makes it into .Net 6 capacity permitting. This would make Blazor far more palatable in a larger development organization that primarily uses Angular. Right now the argument is, “If you do that in Blazor you can’t use it anywhere else”.

If I have to hear that for the entirety of 2022 I will [cries in Blazor].

5reactions
SteveSandersonMScommented, Jul 26, 2021

Done

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dynamically add component to Root Container - Ignition
I want to dynamically add a custom component to root container but I get an error saying: Cannot add directly to a container....
Read more >
Dynamically add components to the DOM with Angular
1. Dynamic Component. First of all, we'll create the Component to be dynamically added to the DOM: import { Component } from '@angular/core'@Component({...
Read more >
ReactJS - Root DOM node dynamically added
I have a tabbed interface controlled by jquery in a legacy application. I am migrating new parts to ReactJS. One of the tabs...
Read more >
UProperties and Dynamically created components - C++
I've been trying to figure out how to add components to an object at runtime. After looking it up, I found using NewObject...
Read more >
Dynamic component loader
This cookbook shows you how to add components dynamically. ... Angular comes with its own API for loading components dynamically.
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