Reputation: 33
I have a parent component in Blazor in which child component is placed.
<div class="margin-top-50">
<ChildComponent someparameters/>
</div>
Now if the child component is not generating any markup based upon parameters passed, I don't want to render the div tag also in the parent component. How can I achieve this?
Upvotes: 1
Views: 406
Reputation: 3285
Would it be an option to put the outer div inside of ChildComponent
?
Inside ChildComponent.razor
<div class="margin-top-50">
... the rest of the component as it is now
</div>
In case you render that component somewhere else, and you don't need the div there, then you can remove the margin in the component based on the passed in parameters - the same parameters that define whether there's any markup being generated.
Upvotes: 1