File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
src/LiveComponent/src/Util Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -30,8 +30,11 @@ public function __construct(private readonly ComponentStack $componentStack)
30
30
31
31
public function getCurrentLiveComponent (): ?MountedComponent
32
32
{
33
+ static $ cacheLive = [];
34
+
33
35
foreach ($ this ->componentStack as $ mountedComponent ) {
34
- if ($ this ->isLiveComponent ($ mountedComponent ->getComponent ()::class)) {
36
+ $ componentClass = $ mountedComponent ->getComponent ()::class;
37
+ if ($ cacheLive [$ componentClass ] ??= $ this ->isLiveComponent ($ componentClass )) {
35
38
return $ mountedComponent ;
36
39
}
37
40
}
@@ -41,9 +44,7 @@ public function getCurrentLiveComponent(): ?MountedComponent
41
44
42
45
private function isLiveComponent (string $ classname ): bool
43
46
{
44
- static $ cache = [];
45
-
46
- return $ cache [$ classname ] ??= [] !== (new \ReflectionClass ($ classname ))->getAttributes (AsLiveComponent::class);
47
+ return [] !== (new \ReflectionClass ($ classname ))->getAttributes (AsLiveComponent::class);
47
48
}
48
49
49
50
public function getCurrentComponent (): ?MountedComponent
You can’t perform that action at this time.
0 commit comments