Skip to content

Commit

Permalink
revert effect change
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredLunde committed Oct 27, 2021
1 parent 0406836 commit 87eabdd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
6 changes: 4 additions & 2 deletions packages/event/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@react-hook/event",
"version": "1.2.4",
"version": "1.2.5",
"homepage": "https://github.com/jaredLunde/react-hook/tree/master/packages/event#readme",
"repository": "github:jaredLunde/react-hook",
"bugs": "https://github.com/jaredLunde/react-hook/issues",
Expand Down Expand Up @@ -126,7 +126,9 @@
"react-test-renderer": "latest",
"typescript": "latest"
},
"dependencies": {},
"dependencies": {
"@react-hook/passive-layout-effect": "^1.2.1"
},
"peerDependencies": {
"react": ">=16.8"
}
Expand Down
5 changes: 3 additions & 2 deletions packages/event/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from 'react'
import useLayoutEffect from '@react-hook/passive-layout-effect'

function useEvent<
T extends Window = Window,
Expand Down Expand Up @@ -31,12 +32,12 @@ function useEvent(target: any, type: any, listener: any, cleanup: any): void {
const storedListener = React.useRef(listener)
const storedCleanup = React.useRef(cleanup)

React.useEffect(() => {
useLayoutEffect(() => {
storedListener.current = listener
storedCleanup.current = cleanup
})

React.useEffect(() => {
useLayoutEffect(() => {
const targetEl = target && 'current' in target ? target.current : target
if (!targetEl) return

Expand Down
5 changes: 5 additions & 0 deletions packages/event/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1241,6 +1241,11 @@
resolved "https://registry.yarnpkg.com/@react-hook/latest/-/latest-1.0.2.tgz#767eb6974f91eef353981b8b60a87147dadecb18"
integrity sha512-zLtOIToct1EBTbwldkMJsXC2eCsmWOOP7z6UG0M/sCgnPExtIjvVMCpPESvPnMbQzDZytXVy0nvMbUuK2gZs2A==

"@react-hook/passive-layout-effect@^1.2.1":
version "1.2.1"
resolved "https://registry.yarnpkg.com/@react-hook/passive-layout-effect/-/passive-layout-effect-1.2.1.tgz#c06dac2d011f36d61259aa1c6df4f0d5e28bc55e"
integrity sha512-IwEphTD75liO8g+6taS+4oqz+nnroocNfWVHWz7j+N+ZO2vYrc6PV1q7GQhuahL0IOR7JccFTsFKQ/mb6iZWAg==

"@rollup/plugin-babel@^5.0.2":
version "5.0.2"
resolved "https://registry.yarnpkg.com/@rollup/plugin-babel/-/plugin-babel-5.0.2.tgz#d9351b9545b0c586a193fc99830d4b1a25317ed5"
Expand Down

0 comments on commit 87eabdd

Please sign in to comment.