Components without ChildContent dont throw exception when used with contents if shown conditionally
Consider this component:
<div>
@Test
</div>
@functions
{
public string Test { get; set; } = "Testing";
}
Works fine if you use it like this somewhere in a page:
<MyComponent></MyComponent>
But if you (accidently) add content to it, like this:
<MyComponent>Do not do this</MyComponent>
It will throw a nice exception, something like: 'Object of type 'Components.MyComponent' does not have a property matching the name 'ChildContent'.
Fine
Now, when I want to show this component conditionally, like so:
@if (show)
{
<MyComponent>Do not do this</MyComponent>
}
And make a button to set 'show = true' then nothing happens. No component is shown which is maybe to be expected, but there is also no exception, which I do expect.
I think you might have to call StateHasChanged() when you set show=true
Oh wait.. you are right.. My bad.
This StateHasChanged thing keeps biting me..