Skip to content

updating skip from false to true after initial run does not kill observer. #466

Description

@rayventerprise

I have a state property that will toggle the "skip" property as a performance helper since I am using the hook on 50+ comps. However I notice when skip is set to true after the node was already set, the observer will not remove itself causing needless state updates.

`
const [disableObserving, setDisableObserving] = useState(false)

const {inViewRef, inView} = useInView({
skip: disableObserving
})

// inViewRef() is called somewhere down the road

useEffect(() => {
setTImeout(() => {
setDisableObserving(true)
}, 1000)
}, [])

useEffect(() => {
console.log('still flips to true or false even when I have skip set to true at this exact moment.')
}, [inView])

`

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions