Closed TLabWest closed 3 years ago
Hi @TLabWest,
Thanks for raising this, I can replicate but I think it's to do with the initial import of the observer js which occurs when the service is initialised.
The <IntersectionObserve>
component does check to initialise the observer after render:
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
await this.InitialiseObserver();
}
}
Will be looking into this and let you know when it's been fixed.
Thanks!
This is fixed in the latest release #23, however it does contain a breaking change in relation to the component so please be aware of that!
In a Blazor-Server setup I get the following error during startup:
To reproduce the error, simply add the
<IntersectionObserve>
component to a Blazor (.razor) component and launch the Blazor Server app. Unfortunately I don't have a small repro project right now, I could get back to you with one should it still be needed.NB: It still works, it's just flooding my error log with unsightly call stacks. I have worked around the problem by flagging a bool in my own
OnAfterRenderAsync()
and only including the<IntersectionObserve>
component conditionally when that flag is set. Still, this should probably be handled more centrally in theIntersectionObserve
component itself.More information and simple examples can be found here: https://docs.microsoft.com/en-us/aspnet/core/blazor/call-javascript-from-dotnet?view=aspnetcore-5.0#detect-when-a-blazor-server-app-is-prerendering