How to fix ‘The current thread is not associated with the renderer’s synchronization context’?

I have just implemented a State Container like this and ran into the same error – but my service needs to be a singleton. So I found an example on the aspnetcore git that does exactly what the error message says to do. Call InvokeAsync — not from your state container but when you try … Read more

Blazor – cannot convert from ‘method group’ to ‘EventCallback’

You were close: <ChildComponent Item=”someModel” T=”SomeModel” DeleteCallback=”OnDeleteSomeModel” /> @code { SomeModel someModel = new SomeModel(); void OnDeleteSomeModel(SomeModel someModel) { … } } The EventCallback uses a generic type and blazor cannot infer it if you don’t pass the type to the component. This means that if you have a EventCallback<T> you need to pass the … Read more

Blazor component : refresh parent when model is updated from child component

Create a shared service. Subscribe to the service’s RefreshRequested event in the parent and Invoke() from the child. In the parent method call StateHasChanged(); public interface IMyService { event Action RefreshRequested; void CallRequestRefresh(); } public class MyService: IMyService { public event Action RefreshRequested; public void CallRequestRefresh() { RefreshRequested?.Invoke(); } } //child component MyService.CallRequestRefresh(); //parent component … Read more