
Even experienced developers hit the same Blazor WASM pitfalls. Here are the most common and exactly how to avoid them.
When state changes outside Blazor's event cycle (timers, SignalR), the UI won't update. Fix: call await InvokeAsync(StateHasChanged).
Subscribing to AppState's OnChange without unsubscribing causes leaks. Fix: implement IDisposable and unsubscribe in Dispose().
Modifying a [Parameter] property directly breaks one-way data flow. Fix: use EventCallback to notify the parent.
JS interop fails if called before OnAfterRenderAsync(firstRender: true). Always place JS calls inside the firstRender guard.
GetFromJsonAsync returns null on 204 or empty body. Always null-coalesce: data = await Http.GetFromJsonAsync<List<T>>(url) ?? new();
Refreshing on any non-root URL returns 404 unless the server returns index.html for all routes.
Reference:
TaskLoco™ — The Sticky Note GOAT