Difference between @aware and @props directives in laravel 9

1.9k views Asked by At

The @aware Laravel Blade template directive was introduced in Laravel 8, but I still don't understand what it does differently from the already existing @props directive.

For instance, if I use a Blade template like this:

<x-view-content :page="$page ?? ''" />

and the component used above is defined in views/components/view-content.blade.php like this:

@aware(['page'])

<div>
    {{ $page }}
</div>

I get the page successfully rendered inside the component. However, replacing @aware(['page']) with @props(['page']) produces the same result.

I would like to know what the differences between them are.

1

There are 1 answers

0
knubbe On

@aware is for accessing data from a parent component where you have @props. You can find here all relevant information. In your case you don't have child component.