This post indicates I should be using hard coded values. However it does not spell out how to deal with loops. What is the correct way? Does using builder.SetKey(model); circumnavigate the problem? The code is working without issue. I just want to clear this up before making a repo public for this NuGet package
protected override void BuildRenderTree(RenderTreeBuilder builder)
{
...
int i = 3;
foreach (object model in models)
{
(Type componentType, string propertyName) viewComponentInfo = GetModelViewComponentInfo(model);
Type componentType = viewComponentInfo.componentType;
if (componentType is not null)
{
string propertyName = string.IsNullOrWhiteSpace(viewComponentInfo.propertyName) ? "Model" : viewComponentInfo.propertyName;
builder.OpenComponent(i++, componentType);
builder.AddAttribute(i++, propertyName, model);
builder.SetKey(model);
builder.CloseComponent();
}
}
...
}