Skip to content
This repository was archived by the owner on Mar 6, 2022. It is now read-only.

Commit b2ae217

Browse files
fix: attach and remove screenful listener on every side effect instead of the first mount
1 parent 3237cf7 commit b2ae217

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

example/.eslintcache

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[{"/Users/emiliano/Desktop/projects/react-spring-carousel/example/src/index.tsx":"1","/Users/emiliano/Desktop/projects/react-spring-carousel/example/src/App.tsx":"2"},{"size":164,"mtime":1607363608058,"results":"3","hashOfConfig":"4"},{"size":4894,"mtime":1612209545613,"results":"5","hashOfConfig":"4"},{"filePath":"6","messages":"7","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"8"},"bpxiyg",{"filePath":"9","messages":"10","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/Users/emiliano/Desktop/projects/react-spring-carousel/example/src/index.tsx",[],["11","12"],"/Users/emiliano/Desktop/projects/react-spring-carousel/example/src/App.tsx",[],{"ruleId":"13","replacedBy":"14"},{"ruleId":"15","replacedBy":"16"},"no-native-reassign",["17"],"no-negated-in-lhs",["18"],"no-global-assign","no-unsafe-negation"]
1+
[{"/Users/emiliano/Desktop/projects/react-spring-carousel/example/src/index.tsx":"1","/Users/emiliano/Desktop/projects/react-spring-carousel/example/src/App.tsx":"2"},{"size":164,"mtime":1607363608058,"results":"3","hashOfConfig":"4"},{"size":4904,"mtime":1612255022820,"results":"5","hashOfConfig":"4"},{"filePath":"6","messages":"7","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"8"},"bpxiyg",{"filePath":"9","messages":"10","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/Users/emiliano/Desktop/projects/react-spring-carousel/example/src/index.tsx",[],["11","12"],"/Users/emiliano/Desktop/projects/react-spring-carousel/example/src/App.tsx",[],{"ruleId":"13","replacedBy":"14"},{"ruleId":"15","replacedBy":"16"},"no-native-reassign",["17"],"no-negated-in-lhs",["18"],"no-global-assign","no-unsafe-negation"]

example/src/App.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ const App = () => {
205205
}
206206
})
207207

208-
useListenToCustomEvent('onSlideChange', (data) => {
209-
console.log('slide change!', data)
208+
useListenToCustomEvent('onFullscreenChange', (data) => {
209+
console.log('onFullscreenChange', data)
210210
})
211211

212212
return (

src/modules/useFullscreenModule.tsx

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { useRef, MutableRefObject } from 'react'
2-
import { prepareDataForCustomEvent, useMount } from '../index.utils'
1+
import { useRef, MutableRefObject, useEffect } from 'react'
2+
import { prepareDataForCustomEvent } from '../index.utils'
33
import screenfull from 'screenfull'
44
import { EmitCustomEvent, OnFullscreenChange } from '..'
55

@@ -16,7 +16,8 @@ export function useFullscreenModule({
1616
}: FullscreenModule) {
1717
const isFullscreen = useRef(false)
1818

19-
useMount(() => {
19+
// @ts-ignore
20+
useEffect(() => {
2021
function handleFullscreenChange() {
2122
if (document.fullscreenElement) {
2223
setIsFullscreen(true)
@@ -51,8 +52,6 @@ export function useFullscreenModule({
5152
}
5253
}
5354
}
54-
55-
return () => {}
5655
})
5756

5857
function setIsFullscreen(_isFullscreen: boolean) {

0 commit comments

Comments
 (0)