Skip to content

Conversation

@jacksleight
Copy link
Contributor

@jacksleight jacksleight commented Nov 25, 2025

Statamic cascade data is currently only available during the initial component render, it is not available in update renders.

This PR adds a new Cascade attribute that can be applied to the component class to enable autoloading of cascade data in the components view during all renders.

The implementation mirrors the @cascade Blade directive (https://statamic.dev/blade#cascade-directive). You can specify an array of cascade variables to include, fallback values if variables are missing, or exclude the array to load everything. Specifying a missing variable with no fallback will throw an exception.

use MarcoRieser\Livewire\Attributes\Cascade;

#[Cascade]
class Listing extends Component
{
    // ...
}
use MarcoRieser\Livewire\Attributes\Cascade;

#[Cascade([
	'homepage',
	'my_globals' => [],
])]
class Listing extends Component
{
    // ...
}

The attribute has no effect in Blade views.

@jacksleight jacksleight marked this pull request as draft November 25, 2025 15:09
@jacksleight jacksleight marked this pull request as ready for review November 25, 2025 15:15
@marcorieser
Copy link
Owner

marcorieser commented Nov 25, 2025

Brilliant, thanks! ❤️ I'll give it a test and merge it afterwards.

@marcorieser marcorieser merged commit f97d4a7 into marcorieser:main Jan 16, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants