I'm trying to return a RenderFragment
from a component private method,
but I'm getting the compilation error:
'__builder' does not exist in the current context
here's the minimum code that shows the problem:
<div>
@RenderButton(1)
</div>
@code {
private RenderFragment RenderButton(int number)
{
return builder =>
{
<button type="button">@number</button>
};
}
}
it appears to me that this might not be possible/allowed, if not, is there any way to avoid having to write the same render code?, let's say that I need to use this RenderButton
method in multiple loops, and if else blocks
edit: the only solution I can think of now is to create a component for each of these RenderFragment
methods