Add RendererInfo examples (#34116)
parent
38acaae8cc
commit
a681ae87a0
|
@ -226,7 +226,30 @@ The <xref:Microsoft.AspNetCore.Components.ComponentBase.RendererInfo?displayProp
|
||||||
* `InteractiveAuto` for Interactive Auto.
|
* `InteractiveAuto` for Interactive Auto.
|
||||||
* `InteractiveWebAssembly` for Interactive WebAssembly.
|
* `InteractiveWebAssembly` for Interactive WebAssembly.
|
||||||
|
|
||||||
Components use these properties to render content depending on their location or interactivity status. For example, a form can be disabled during prerendering and enabled when the component becomes interactive:
|
Components use these properties to render content depending on their location or interactivity status. The following examples demonstrate typical use cases.
|
||||||
|
|
||||||
|
Display content until a component is interactive:
|
||||||
|
|
||||||
|
```razor
|
||||||
|
@if (!RendererInfo.IsInteractive)
|
||||||
|
{
|
||||||
|
<p>Connecting to the assistant...</p>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Disable a button until a component is interactive:
|
||||||
|
|
||||||
|
```razor
|
||||||
|
<button @onclick="Send" disabled="@(!RendererInfo.IsInteractive)">
|
||||||
|
Send
|
||||||
|
</button>
|
||||||
|
```
|
||||||
|
|
||||||
|
Disable a form during prerendering and enable the form when the component is interactive:
|
||||||
|
|
||||||
```razor
|
```razor
|
||||||
<EditForm Model="Movie" ...>
|
<EditForm Model="Movie" ...>
|
||||||
|
@ -256,7 +279,7 @@ Components use these properties to render content depending on their location or
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
The next example shows how to render markup to support performing a regular HTML action if the component is statically rendered:
|
Render markup to support performing a regular HTML action if the component is statically rendered:
|
||||||
|
|
||||||
```razor
|
```razor
|
||||||
@if (AssignedRenderMode is null)
|
@if (AssignedRenderMode is null)
|
||||||
|
|
Loading…
Reference in New Issue