Skip to content

Commit

Permalink
fix render sequence issue
Browse files Browse the repository at this point in the history
  • Loading branch information
pwelter34 committed Apr 12, 2024
1 parent f6a9948 commit 3ce92d5
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 19 deletions.
4 changes: 2 additions & 2 deletions samples/Sample.ClientSide/Sample.ClientSide.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.4" PrivateAssets="all" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="System.Net.Http.Json" Version="8.0.0" />
</ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions samples/Sample.Core/Sample.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Bogus" Version="35.4.1" />
<PackageReference Include="Bogus" Version="35.5.0" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageReference Include="System.Net.Http.Json" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components" Version="8.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Components" Version="8.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.4" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/LoreSoft.Blazor.Controls/Conditional.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)
}
else if (ChildContent != null)
{
builder.AddContent(1, ChildContent);
builder.AddContent(2, ChildContent);
}
}
else if (Failed != null)
{
builder.AddContent(1, Failed);
builder.AddContent(3, Failed);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/LoreSoft.Blazor.Controls/LoreSoft.Blazor.Controls.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components" Version="8.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Components" Version="8.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.4" />
</ItemGroup>

<ItemGroup>
Expand Down
10 changes: 3 additions & 7 deletions src/LoreSoft.Blazor.Controls/Repeater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ namespace LoreSoft.Blazor.Controls;

public class Repeater<TItem> : ComponentBase
{
private int _sequence = 0;

[Parameter, EditorRequired]
public IEnumerable<TItem> Items { get; set; }

Expand All @@ -23,15 +21,13 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)
{
foreach (var item in Items)
{
builder.AddContent(Next(), Row, item);
builder.AddContent(1, Row, item);
builder.SetKey(item);
}
}
else if (Empty != null)
{
builder.AddContent(Next(), Empty);
builder.AddContent(2, Empty);
}
}

protected int Next() => _sequence++;

}
8 changes: 5 additions & 3 deletions src/LoreSoft.Blazor.Controls/StateProvider.razor.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

using Microsoft.AspNetCore.Components;

namespace LoreSoft.Blazor.Controls;
Expand All @@ -7,17 +9,17 @@ public partial class StateProvider<TState>
[Parameter]
public required RenderFragment ChildContent { get; set; }

public event Action<object> OnStateChange;
public event Action<object?>? OnStateChange;

public TState? State { get; protected set; }

public virtual void Set(TState model)
public virtual void Set(TState? model)
{
State = model;
NotifyStateChanged(this);
}

public void NotifyStateChanged(object sender = null)
public void NotifyStateChanged(object? sender = null)
{
StateHasChanged();
OnStateChange?.Invoke(sender);
Expand Down

0 comments on commit 3ce92d5

Please sign in to comment.