From c0cc35107b4b5d173789549c729144d8009db66a Mon Sep 17 00:00:00 2001 From: Diego Betto <11378282+diego-betto@users.noreply.github.com> Date: Thu, 19 Mar 2026 13:18:58 +0100 Subject: [PATCH] Implement render method in ExampleComponent Add render method to ExampleComponent for view rendering. --- sage/components.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/sage/components.md b/sage/components.md index a41b292f..9749bfee 100644 --- a/sage/components.md +++ b/sage/components.md @@ -60,6 +60,7 @@ In turn, the class might look like this: namespace App\View\Components; use Roots\Acorn\View\Component; +use Illuminate\View\View; class ExampleComponent extends Component { @@ -79,10 +80,25 @@ class ExampleComponent extends Component if (!is_numeric($this->imageId)) { return false; } - + return wp_get_attachment_image($this->imageId, 'medium_large'); } + + /** + * Get the view / contents that represent the component. + */ + public function render(): View + { + return view('components.example-component'); + // or a view string: + // return <<<'blade' + //
+ // Hello World! + //
+ // blade; + } } + ``` ## Argument and attribute names