Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OnInitializedAsync VS OnParametersSetAsync To call Web API

Tags:

blazor

I'm new to blazor and still learning

I have two components in my page, the first one is used to take same user inputs and the second component is used to fetch data from an API based on user input on the first component

I'm calling OnInitializedAsync to fetch data from API, but since this method is not called after re-rendering the component i'm using OnParametersSetAsync

my question is what's the difference between fetching data using OnInitializedAsync VS OnParametersSetAsync , which one should i use ?

like image 621
CSharp-n Avatar asked Sep 11 '25 16:09

CSharp-n


1 Answers

use

OnParametersSetAsync()

OnParametersSetAsync are called each time new or updated parameters are received from the parent in the render tree

like image 95
novfal haq Avatar answered Sep 14 '25 11:09

novfal haq



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!