Blade component gotcha
This title could be clearer and more informative.Try out Clickbait Shieldfor free (5 uses left this month).
A gotcha in Laravel's Blade anonymous components causes Eloquent models (or any object implementing `__toString`) to be silently serialized to JSON every time the component is instantiated. This happens inside the `sanitizeComponentAttribute` function in the Blade compiler. The workaround is to use class-based components instead of anonymous ones, passing props through constructor arguments to avoid the unnecessary JSON serialization. A fix has since been merged into the Laravel framework.
Sort: