Skip to content

Commit 2262235

Browse files
committed
Improve prop lazy evaluation
1 parent 727a3e7 commit 2262235

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/Response.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,10 @@ public function withViewData($key, $value = null)
4949
public function toResponse($request)
5050
{
5151
$only = array_filter(explode(',', $request->header('X-Inertia-Only')));
52-
$props = $only ? array_only($this->props, $only) : $this->props;
5352

54-
array_walk_recursive($props, function (&$prop) {
55-
if ($prop instanceof Closure) {
56-
$prop = App::call($prop);
57-
}
58-
});
53+
$props = array_map(function ($prop) {
54+
return $prop instanceof Closure ? App::call($prop) : $prop;
55+
}, $only ? array_only($this->props, $only) : $this->props);
5956

6057
$page = [
6158
'component' => $this->component,

0 commit comments

Comments
 (0)