OnInitializedAsync VS OnParametersSetAsync To call Web API

Viewed 1241

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 ?

1 Answers

use

OnParametersSetAsync()

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

Related