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)
3030
3131 public function getCurrentLiveComponent (): ?MountedComponent
3232 {
33+ static $ cacheLive = [];
34+
3335 foreach ($ this ->componentStack as $ mountedComponent ) {
34- if ($ this ->isLiveComponent ($ mountedComponent ->getComponent ()::class)) {
36+ $ componentClass = $ mountedComponent ->getComponent ()::class;
37+ if ($ cacheLive [$ componentClass ] ??= $ this ->isLiveComponent ($ componentClass )) {
3538 return $ mountedComponent ;
3639 }
3740 }
@@ -41,9 +44,7 @@ public function getCurrentLiveComponent(): ?MountedComponent
4144
4245 private function isLiveComponent (string $ classname ): bool
4346 {
44- static $ cache = [];
45-
46- return $ cache [$ classname ] ??= [] !== (new \ReflectionClass ($ classname ))->getAttributes (AsLiveComponent::class);
47+ return [] !== (new \ReflectionClass ($ classname ))->getAttributes (AsLiveComponent::class);
4748 }
4849
4950 public function getCurrentComponent (): ?MountedComponent
You can’t perform that action at this time.
0 commit comments