Closed bmarinsek closed 3 years ago
Can you upload your reproduction to a public repository rather than a zip file?
You need to either read directly from the state, which is updated by the time the Dispatch call has finished, like so
jsRuntime.InvokeVoidAsync("alert", applicationState.Value.Application.Detail.DetailInformation);
Or, if you want your component to be passed state instead of receiving it from your store, you have to access it in OnParametersSet
. Note the HasRendered
is only there because you are invoking Javascript.
bool HasRendered;
protected override void OnAfterRender(bool firstRender)
{
base.OnAfterRender(firstRender);
HasRendered = true;
}
protected override void OnParametersSet()
{
base.OnParametersSet();
if (HasRendered)
jsRuntime.InvokeVoidAsync("alert", Detail.DetailInformation);
}
And also, don't alter state in code
applicationState.Value.Application.Detail = new Detail()
{
DetailInformation = "Second text"
};
Hi!
Please check the provided blazor application and it's behaviour!
Steps to reproduce the problem:
Why state wont change when i create new object inside state object? When i change only property it works fine.
(Note: Detail object is used as a parameter to the TestComponent)
Is this the expected behaviour?
WebApplication11.zip
Thank you very much for any suggestion about this issue.