Skip to content

Commit b6af64d

Browse files
committed
refactor: fix dimensions event removal deprecation handler
1 parent 3533883 commit b6af64d

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

ios/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1347,7 +1347,7 @@ SPEC CHECKSUMS:
13471347
Segment-Appboy: 3ccf7ffd34701e11029e1d013e57eae0756a8eb1
13481348
Sentry: 71cd4427146ac56eab6e70401ac7a24384c3d3b5
13491349
SentryPrivate: 9334613897c85a9e30f2c9d7a331af8aaa4fe71f
1350-
Sift: 8cd26419e0a9b0d94bd733b296353b68c44192aa
1350+
Sift: 7c27188ba3533c0a1be541d7efb68384e17e544c
13511351
sift-react-native: 9ed8bc21788e3233399eaf196425246442aa7dee
13521352
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
13531353
Specta: 3e1bd89c3517421982dc4d1c992503e48bd5fe66

src/app/Components/HeaderArtworksFilter/HeaderArtworksFilter.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
import { FilterIcon, Flex, Box, Text, Separator } from "@artsy/palette-mobile"
1+
import {
2+
FilterIcon,
3+
Flex,
4+
Box,
5+
Text,
6+
Separator,
7+
TouchableHighlightColor,
8+
} from "@artsy/palette-mobile"
29
import { isPad } from "app/utils/hardware"
3-
import { TouchableHighlightColor } from "@artsy/palette-mobile"
10+
import { useScreenDimensions } from "app/utils/hooks"
411
import React, { useEffect, useState } from "react"
512
import { Animated, Dimensions, LayoutChangeEvent, PixelRatio } from "react-native"
6-
import { useScreenDimensions } from "app/utils/hooks"
713

814
export interface FilterProps {
915
total: number
@@ -61,10 +67,8 @@ export const HeaderArtworksFilter: React.FC<FilterProps> = ({ total, animationVa
6167

6268
useEffect(() => {
6369
// orientation changed, allow for recalculation of pageY
64-
Dimensions.addEventListener("change", orientationChanged)
65-
return () => {
66-
Dimensions.removeEventListener("change", orientationChanged)
67-
}
70+
const dimensionsEventSubscription = Dimensions.addEventListener("change", orientationChanged)
71+
return () => dimensionsEventSubscription.remove()
6872
}, [])
6973

7074
const orientationChanged = () => {

src/app/utils/hooks/useScreenDimensions.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,8 @@ export const ProvideScreenDimensions: React.FC = ({ children }) => {
4343
const onChange = () => {
4444
setDimensions(getCurrentDimensions())
4545
}
46-
Dimensions.addEventListener("change", onChange)
47-
return () => {
48-
Dimensions.removeEventListener("change", onChange)
49-
}
46+
const dimensionsEventSubscription = Dimensions.addEventListener("change", onChange)
47+
return () => dimensionsEventSubscription.remove()
5048
}, [])
5149

5250
return (

0 commit comments

Comments
 (0)