Git Product home page Git Product logo

next-router-scroll's Issues

proposal: Update README Examples

Hi there team!

Your package here is stupendous and valuable, so thank you for your hard work! This topic is, somehow, not super easy for some reason. You'd think, the browser should just do its thing and โœ… ?

A common use case that I ran into is waiting for a specific element to render before updateScroll is called. I read over the README and I read over your tests (thanks for adding those!). Unfortunately, I couldn't quite piece together just "how" registering an element would allow me to "wait for it to render" before updating scroll.

So what I did instead was use the update ref pattern that React outlines here.

My implementation ended up looking a little like this:

const MyComponent = () => {
  const divRef = useCallback(
    (node) => {
      if (node !== null) {
        updateScroll();
      }
    },
    [updateScroll]
  );

  return (
    <div ref={divRef}>hi</div>
  );
}

This ended up working pretty well for me, and allowed me to explicitly wait for a node to appear before updating scroll.

The reason I'm opening this issue, is I'm wondering if the README could be more clear about how to use registerElement and updateScroll together. If the intended use case for those is not similar to the above implementation, would it be valuable to add an example that showed how to do something like this?

Thanks again for all your hard work!

[ASK]Typescript Definition File Required

Please tell me about the plan to open the declaration file for typescript user.

If you don't have any plan for now, then can I pull request the declare file?

Thank you for your attention.

Upgrading to Next.js V12

Will next-router-scroll be updated so it is compatible with Next.js version 12? Currently peer and dev dependencies are atmost version 11.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.