# Render Scope

**Path:** Components/Advanced

[Back to Documentation Index](http://rubicblazor.skyconis.com/docs.md)

---

Render Scope

 RbRenderScope limits child rendering to explicit moments instead of allowing every parent
 StateHasChanged() call to flow through automatically.

 Use it when child content is expensive, visually noisy, or should refresh only on demand.
 The same behavior is also available through RbRenderScope as a compatibility alias.

 When To Use
 Wrap expensive fragments that should not rerender on every parent state change.

 Refresh a section only after a button click, filter apply, or explicit workflow step.

 Run a post-render callback with OnRenderCompleted when DOM-dependent work must happen after the gated render finishes.

 Parent Always Renders

 The parent can render freely while the scoped fragment stays frozen after its initial render.

 Show code

 Invoke StateHasChanged 

 Normal content 

 Parent render tick: 1 

 Scoped content 

 This block renders only on first load because AllowRender was never opened.

 Scoped render tick: 1 

 Render On Request

 This is the common @bind-AllowRender flow: open the gate, render once, and let the component push
 the flag back to false .

 Show code

 The parent can rerender many times, but the child fragment updates only when
 AllowRender becomes true .

 Requested content 

 Scoped render tick: 639227312464457456 

 After rendering, the component automatically pushes false back through AllowRenderChanged . 

 AllowRender = true 

 Parent StateHasChanged 

 Sticky Parent Rule

 Advanced scenarios can handle AllowRenderChanged manually and keep the parent-side flag sticky.

 Show code

 Some flows want to keep the parent-side flag checked while still preventing duplicate renders inside the same cycle.
 This pattern shows custom AllowRenderChanged handling.

 Sticky content 

 Scoped render tick: 639227312464458577

 Keep AllowRender checked 

 Render Completed Callback

 Use OnRenderCompleted for DOM-dependent work that must run only after the scoped content really rendered.

 Show code

 OnRenderCompleted runs after the scoped fragment really rendered, so it is the right place for
 measurement, focus, scrolling, or JS interop that depends on fresh DOM.

 Callback content 

 Scoped render tick: 639227312464459099

 Render Scoped Content 

 Completed count: 0 
 Last firstRender: - 

 API

 RbRenderScope

 A render gate component that hosts child content and allows that content to rerender only when explicitly enabled.

 AllowRender

 Opens the render gate for the next scoped render. When false, parent rerenders do not refresh the child fragment.

 Parameters

 bool AllowRender = false

 Set to true when you want the wrapped content to rerender on the next cycle.

 AllowRenderChanged

 Raised after a successful scoped render so the parent can sync its flag back to false or apply custom state rules.

 Parameters

 EventCallback<bool> AllowRenderChanged 

 Usually used through @bind-AllowRender . Advanced flows can handle it manually for sticky or conditional parent state.

 OnRenderCompleted

 Callback executed after the scoped content actually rendered.

 Parameters

 Func<bool, Task> OnRenderCompleted 

 Receives firstRender so you can distinguish initial render from later requested renders.

 Return

 Task 

 Complete the task when any post-render work, such as JS interop or focus logic, is done.

 ChildContent

 The fragment protected by the render gate.

 Parameters

 RenderFragment ChildContent 

 Place the expensive or controlled UI subtree here.

 ✕

 Contents
