I have my Blazor component with some JavaScript code. When there is a click detected by the JavaScript code, I want to call an JSInvokable function in my Blazor component to update the UI.
So, I created a function like this
[JSInvokable]public static async Task ChangeTab(string val){ Console.WriteLine(val);}in the JavaScript, I added the following line:
DotNet.invokeMethodAsync('myComponent', 'ChangeTab', tabText);This code is working and the function ChangeTab receives the value I expected. The problem is that this function is static. So, I can't change the variables. I tried to change the code like this (ActivatePage is a function in the component)
[JSInvokable("ChangeTab")]public async Task ChangeTab(string val){ ActivatePage(val);}but in this case I get an error because the function is not static.
Error: System.ArgumentException: The assembly 'PSC.Blazor.Components.ScrollTabs' does not contain a public invokable method with [JSInvokableAttribute("ChangeTab")]
I checked the Microsoft documentation but I don't understand how to change the JSInvokable function to not be static.
