Blazor Explicit Rendering #58871
Labels
area-blazor
Includes: Blazor, Razor Components
✔️ Resolution: Answered
Resolved because the question asked by the original author has been answered.
Needs: Attention 👋
This issue needs the attention of a contributor, typically because the OP has provided an update.
Status: Resolved
Is there an existing issue for this?
Is your feature request related to a problem? Please describe the problem.
There are many use cases where:
A very simple example below: When you try to call _myRef it is null as it has not rendered yet. There are a bunch of ways usually hacky to get around the issue. Other similar issues have been raised by other individuals for example #49048
Describe the solution you'd like
What we have started to do is created our own function "RenderAsync" that creates a task then manually resolve it in the OnAfterRender event. This has worked out quite well and reduces other much hackier code. We've also made this into a base class to promote re-use / organization.
So then our function referenced above changes to look like the below and now _myRef is no longer null.
I think our solution is still a bit hacky however and there is most likely some use cases where this strategy is going to cause a bug. I think it would be beneficial to have a built in function that accomplishes the same thing as RenderAsync() that is properly unit tested / signed off on by the core Blazor team.
Additional context
No response
The text was updated successfully, but these errors were encountered: