I have a dynamicly own tabs on c#,Html,css and some Js. Js just toggle style "Display" to block or none. Tabs generate with foreach.
Example:
foreach (item in TabsList){<div@RenderFragment/<div}
Main problem: In my tabs there are some actions and data and I dont want to lose it when I Add or Delete other Tab. If I add new Tab then it will normal render without ReRender old tabs and lose data, but if I Remove from List tab which located to the left of the current selected tab then Blazor will ReRender all my Tabs and I will lose My Data. But if i remove tab to the right of the current selected tab Blazor will not ReRender All my Tabs. Is it Possible tell Blazor just remove item from TabsList and not to Rerender again my component?
CodePudding user response:
This might be solvable with the @key attribute.
Without a [mre] it's not possible to be sure, you can test it:
foreach (item in TabsList){ <div @key="item">@RenderFragment</div> }
CodePudding user response:
You should set the shouldRender() method to false inside the component (this will prevent the re-render everytime you call the component, only render the first time), anyway, like a year ago, they try to solve this issue in this thread on git where there is a lot of info about the topic!