Reactive children are never skipped when a prop is an array, or when the parent doesn't render
Livewire version
v4.4.6
Laravel version
v13.32.0
PHP version
8.5.3
Browser and operating system
Chrome 153 on macOS
Describe the issue you're experiencing
#10195 made the server skip a bundled #[Reactive] child whose props didn't change. It never skips in two cases:
- Array props.
SupportReactiveProps::valuesMatch()compares$snapshot['data'][$prop]with the parent's raw param. The snapshot holds the dehydrated value ([{"period":"this_year"},{"s":"arr"}]), the parent passes the plain array ({"period":"this_year"}), so the two JSON encodings never match and the child always re-renders. Scalars match because they aren't synthesized. Models match becausemodelMatchesSnapshot()already reads the dehydrated form. Every other synthesized value (arrays, collections, Carbon, enums) misses out. The existingtest_values_match_returns_true_for_equal_scalars_and_arrayspasses only because it uses raw arrays on the snapshot side, which never happens in a real request. - A parent that doesn't render.
shouldSkipUpdate()returns false when there are no$pendingChildParams, which is also the case when the parent skipped its render (#[Renderless]orskipRender()). The client still bundles every reactive child into the request, so they all fully re-render, although a parent that didn't render can't have passed them anything new.
Together they mean that any action on a component with reactive array props re-renders all its reactive children, even a renderless action that changes nothing. Children that run queries in render() run them on every such request.
Code snippets to reproduce the issue
resources/views/components/⚡parent.blade.php:
<?php
use Livewire\Attributes\Renderless;
use Livewire\Component;
new class extends Component {
public array $filters = ['period' => 'this_year'];
public int $count = 0;
public function inc() { $this->count++; }
#[Renderless]
public function ping() {}
};
?>
<div>
<p>Parent count: {{ $count }}</p>
<button wire:click="inc">Change something unrelated</button>
<button wire:click="ping">Call a renderless method</button>
<livewire:child :filters="$filters" />
</div>resources/views/components/⚡child.blade.php:
<?php
use Livewire\Attributes\Reactive;
use Livewire\Component;
new class extends Component {
#[Reactive]
public array $filters;
public int $renders = 0;
public function rendering() { $this->renders++; }
};
?>
<div>
<p>Child period: {{ $filters['period'] }}</p>
<p>Child renders: {{ $renders }}</p>
</div>Steps:
- Render
<livewire:parent />. The child shows "Child renders: 1". - Click "Change something unrelated".
$filtersdid not change, yet the child now shows "Child renders: 2". - Click "Call a renderless method". The parent doesn't render at all, yet the child shows "Child renders: 3".
Swapping array $filters for string $period makes step 2 skip the child as expected, and step 3 still re-renders it.
Screenshots/screen recordings
No response
How do you expect it to work?
The child is skipped in steps 2 and 3, as it is for an unchanged scalar prop.
I have a fix with tests and will open a PR against 4.x that links this issue.
Please confirm (incomplete submissions will not be addressed)
- I have provided easy and step-by-step instructions to reproduce the bug.
- I have provided code samples as text and NOT images.
- I understand my bug report will be removed if I haven't met the criteria above.
Source: livewire/livewire