diff --git a/README.md b/README.md
index 5371a0e..a7f46ca 100644
--- a/README.md
+++ b/README.md
@@ -117,9 +117,6 @@ Blaze supports all essential features and produces HTML output identical to Blad
- **Class-based components** are not supported
- **The `$component` variable** is not available
- **View composers / creators / lifecycle events** do not fire
-- **Auto-injecting `View::share()` variables** is not supported
-
- Access shared data manually using `$__env->shared('key')`
- **Cross boundary `@aware`** between Blade and Blaze
Both parent and child must use Blaze for values to propagate
diff --git a/src/Compiler/Wrapper.php b/src/Compiler/Wrapper.php
index 12484ec..cea10fb 100644
--- a/src/Compiler/Wrapper.php
+++ b/src/Compiler/Wrapper.php
@@ -67,6 +67,7 @@ public function wrap(string $compiled, string $path, ?string $source = null): st
$output .= 'if (($__data[\'attributes\'] ?? null) instanceof \Illuminate\View\ComponentAttributeBag) { $__data = $__data + $__data[\'attributes\']->all(); unset($__data[\'attributes\']); }'."\n";
$output .= 'extract($__slots, EXTR_SKIP); unset($__slots);'."\n";
$output .= 'extract($__data, EXTR_SKIP);'."\n";
+ $output .= 'extract($__env->getShared(), EXTR_SKIP);'."\n";
$output .= '$attributes = \\Livewire\\Blaze\\Runtime\\BlazeAttributeBag::make($__data, $__bound, $__keys);'."\n";
$output .= 'unset($__data, $__bound, $__keys);'."\n";
$output .= 'ob_start();' . "\n";
diff --git a/tests/Compiler/WrapperTest.php b/tests/Compiler/WrapperTest.php
index 83c5089..1c0c492 100644
--- a/tests/Compiler/WrapperTest.php
+++ b/tests/Compiler/WrapperTest.php
@@ -18,6 +18,7 @@
'if (($__data[\'attributes\'] ?? null) instanceof \Illuminate\View\ComponentAttributeBag) { $__data = $__data + $__data[\'attributes\']->all(); unset($__data[\'attributes\']); } ',
'extract($__slots, EXTR_SKIP); unset($__slots); ',
'extract($__data, EXTR_SKIP); ',
+ 'extract($__env->getShared(), EXTR_SKIP); ',
'$attributes = \Livewire\Blaze\Runtime\BlazeAttributeBag::make($__data, $__bound, $__keys); ',
'unset($__data, $__bound, $__keys); ',
'ob_start(); ?> ',
@@ -44,6 +45,7 @@
'if (($__data[\'attributes\'] ?? null) instanceof \Illuminate\View\ComponentAttributeBag) { $__data = $__data + $__data[\'attributes\']->all(); unset($__data[\'attributes\']); } ',
'extract($__slots, EXTR_SKIP); unset($__slots); ',
'extract($__data, EXTR_SKIP); ',
+ 'extract($__env->getShared(), EXTR_SKIP); ',
'$attributes = \Livewire\Blaze\Runtime\BlazeAttributeBag::make($__data, $__bound, $__keys); ',
'unset($__data, $__bound, $__keys); ',
'ob_start(); ?> ',
diff --git a/tests/IntegrationTest.php b/tests/IntegrationTest.php
index c63a08c..49cd338 100644
--- a/tests/IntegrationTest.php
+++ b/tests/IntegrationTest.php
@@ -4,6 +4,7 @@
use Illuminate\Contracts\View\Engine;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Blade;
+use Illuminate\Support\Facades\View;
use Illuminate\View\Component;
use Livewire\Blaze\Blaze;
use Livewire\Blaze\BlazeManager;
@@ -85,6 +86,14 @@ public function render()
})->assertSee('from-livewire');
});
+test('View::share variables are accessible in components', function () {
+ View::share('sharedValue', 'hello-from-share');
+
+ $html = Blade::render('');
+
+ expect($html)->toContain('hello-from-share');
+});
+
test('folds and compiles the same component', function () {
Blade::render(<<<'BLADE'
{{-- Folded --}}
diff --git a/tests/fixtures/views/components/shared-var.blade.php b/tests/fixtures/views/components/shared-var.blade.php
new file mode 100644
index 0000000..5b6f98e
--- /dev/null
+++ b/tests/fixtures/views/components/shared-var.blade.php
@@ -0,0 +1,3 @@
+@blaze
+
+{{ $sharedValue }}
\ No newline at end of file