You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi
Excuse me for stupid question
I have a blazor page that contains 3 Blazor-components: one display all items, another one is a form to insert new items and the latest show the counter (number of items)
I want use BlazorState.Redux for all the stuff and to share the state (item list)
Can you help me to structure the code correctly?
Possible Solutions
Create a single connected container component that use 3 method Get()
RenderFragment GetComponent01
RenderFragment GetComponent02
RenderFragment GetComponent03
Create 3 separate connected component and in the master page @page "/counter"
As to your question, the general rule is there should be one connected component for one presentational component. For this reason, I would recommend option 2. It is the one that separates concerns best. That is each component is a separate connected component and responsible for its operation. In your example, you would not want to mix logic related to the form with the logic related to the list as those are two separate things. However, there is nothing wrong with the form utilizing the same bits of the state as the list does. That is all done in the connected's component MapStateToProps method. There, you get the whole state object and it is this method responsibility to extract/transform useful bits for its particular component.
Let me know if it is not clear, I can try fixing a small example :)
Hi
Excuse me for stupid question
I have a blazor page that contains 3 Blazor-components: one display all items, another one is a form to insert new items and the latest show the counter (number of items)
I want use BlazorState.Redux for all the stuff and to share the state (item list)
Can you help me to structure the code correctly?
Possible Solutions
Create a single connected container component that use 3 method Get()
RenderFragment GetComponent01
RenderFragment GetComponent02
RenderFragment GetComponent03
Create 3 separate connected component and in the master page
@page "/counter"
@CounterCmp
@CounterCmp1
@CounterCmp2
@code {
RenderFragment CounterCmp = CounterConnected.Get();
RenderFragment CounterCmp1 = Counter1Connected.Get();
RenderFragment CounterCmp2 = Counter2Connected.Get();
}
Really tnx and excuse me for my question that which I imagine is stupid
The text was updated successfully, but these errors were encountered: