Skip to content

Commit

Permalink
initialize with an empy div to ensure initial render redirects for ne…
Browse files Browse the repository at this point in the history
…asted components (#2350)
  • Loading branch information
nuernbergerA committed Jan 20, 2021
1 parent ca2ca53 commit 7a6b84a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/RenameMe/SupportRedirects.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ function __construct()
}

$response->effects['redirect'] = $component->redirectTo;
$response->effects['html'] = $response->effects['html'] ?? '<div></div>';
});
}
}
4 changes: 2 additions & 2 deletions tests/Unit/ComponentSkipRenderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ public function on_redirect_in_mount_render_is_not_called()
$component = Livewire::test(ComponentSkipRenderOnRedirectInMountStub::class);

$this->assertEquals('/foo', $component->payload['effects']['redirect']);
$this->assertNull($component->payload['effects']['html']);
$this->assertNull($component->lastRenderedView);

Route::get('/403', ComponentSkipRenderOnRedirectInMountStub::class);
$this->get('/403')->assertRedirect('/foo');

$component = Livewire::test(ComponentSkipRenderOnRedirectHelperInMountStub::class);

$this->assertStringEndsWith('/bar', $component->payload['effects']['redirect']);
$this->assertNull($component->payload['effects']['html']);
$this->assertNull($component->lastRenderedView);

Route::get('/403', ComponentSkipRenderOnRedirectHelperInMountStub::class);
$this->get('/403')->assertRedirect('/bar');
Expand Down

0 comments on commit 7a6b84a

Please sign in to comment.