motiondivision / motiondivision/motion

[FEATURE] Re-register use in view hook on component re-render

Open
#2,579 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
TypeScript
Stars
33.7k
Forks
1.4k
Avg merge
1d 10h
Merged PRs (30d)
14

Description

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

I have a component that returns null if a state variable is true, and then it returns html/css/markup if the variable is false. If the animation has not happened already the intersection observer from useInView will not be re-registered on the state change. How can I change this behaviour and register the useInView hook again perhaps in a useEffect when my component re-renders.

This functionality is not clear from the docs.

Describe the solution you'd like
A clear and concise description of what you want to happen.

I'd like to be able to re-trigger useInView inside a useEffect so I can reregister the intersection observer. This currently does not seem like support behaviour from the docs.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the useInView hook entry point and trace how its intersection observer is registered when a component changes from returning null to rendering markup. Determine the intended re-registration behavior and how it should be exposed or documented; the issue names no files or tests, so completion criteria need maintainer clarification.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.