File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
src/LiveComponent/src/Util Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change 2424 */
2525final class LiveComponentStack extends ComponentStack
2626{
27+ /** @var array<class-string, bool> */
28+ private array $ cacheLiveComponents = [];
29+
2730 public function __construct (private readonly ComponentStack $ componentStack )
2831 {
2932 }
3033
3134 public function getCurrentLiveComponent (): ?MountedComponent
3235 {
3336 foreach ($ this ->componentStack as $ mountedComponent ) {
34- if ($ this ->isLiveComponent ($ mountedComponent ->getComponent ()::class)) {
37+ $ componentClass = $ mountedComponent ->getComponent ()::class;
38+ if ($ this ->cacheLiveComponents [$ componentClass ] ??= $ this ->isLiveComponent ($ componentClass )) {
3539 return $ mountedComponent ;
3640 }
3741 }
@@ -41,9 +45,7 @@ public function getCurrentLiveComponent(): ?MountedComponent
4145
4246 private function isLiveComponent (string $ classname ): bool
4347 {
44- static $ cache = [];
45-
46- return $ cache [$ classname ] ??= [] !== (new \ReflectionClass ($ classname ))->getAttributes (AsLiveComponent::class);
48+ return [] !== (new \ReflectionClass ($ classname ))->getAttributes (AsLiveComponent::class);
4749 }
4850
4951 public function getCurrentComponent (): ?MountedComponent
You can’t perform that action at this time.
0 commit comments