File tree Expand file tree Collapse file tree
packages/react-native/React/Fabric/Mounting/ComponentViews/View Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1761,21 +1761,22 @@ - (void)viewDidMoveToWindow
17611761
17621762- (void )updateTrackingAreas
17631763{
1764- if (_trackingArea) {
1765- [self removeTrackingArea: _trackingArea];
1766- }
1767-
17681764 BOOL hasMouseEventHandler =
17691765 _props->hostPlatformEvents [HostPlatformViewEvents::Offset::MouseEnter] ||
17701766 _props->hostPlatformEvents [HostPlatformViewEvents::Offset::MouseLeave];
1767+ BOOL wouldRecreateIdenticalTrackingArea =
1768+ hasMouseEventHandler && _trackingArea && NSEqualRects (self.bounds , [_trackingArea rect ]);
17711769
1772- if (hasMouseEventHandler) {
1773- _trackingArea = [[NSTrackingArea alloc ] initWithRect: self .bounds
1774- options: NSTrackingActiveAlways | NSTrackingMouseEnteredAndExited
1775- owner: self
1776- userInfo: nil ];
1777- [self addTrackingArea: _trackingArea];
1778- [self updateMouseOverIfNeeded ];
1770+ if (!wouldRecreateIdenticalTrackingArea) {
1771+ [self removeTrackingArea: _trackingArea];
1772+ if (hasMouseEventHandler) {
1773+ _trackingArea = [[NSTrackingArea alloc ] initWithRect: self .bounds
1774+ options: NSTrackingActiveAlways|NSTrackingMouseEnteredAndExited
1775+ owner: self
1776+ userInfo: nil ];
1777+ [self addTrackingArea: _trackingArea];
1778+ [self updateMouseOverIfNeeded ];
1779+ }
17791780 }
17801781
17811782 [super updateTrackingAreas ];
You can’t perform that action at this time.
0 commit comments