gm0t / react-sticky-el

MIT License
256 stars 47 forks source link

Scroll element is null #82

Open dymarchyk opened 1 year ago

dymarchyk commented 1 year ago

Have a message that Missing required elements: {scrollEl: null, holderEl: div, wrapperEl: div}

Upgrade react to 18 and using nextjs. Problem noticed on nextjs 12 and 13 version.

Try different scrollElement props: window, body or selector. No changes. Try to use dynamic import on client side - also no result.

Has anyone same issue?

martzoukos commented 1 year ago

Same here, it suddenly started showing up and I noticed it just today. I'm using next.js v13 and react v.18.2

dangquanghuy commented 1 year ago

the problem is with: React Strict Mode https://reactjs.org/docs/strict-mode.html. Please turn off or remove </React.StrictMode> in your code.

dangquanghuy commented 1 year ago

can be fixed:

    componentDidUpdate({ scrollElement, boundaryElement, disabled }: RenderProps) {

      if (scrollElement !== this.props.scrollElement || this.scrollEl === null) {
        this.updateScrollEl();
      }

      if (boundaryElement !== this.props.boundaryElement) {
        this.updateBoundaryEl();
      }

      if (disabled !== this.props.disabled) {
        this.disabled = this.props.disabled;
        this.checkPosition();
      }

    }
c7nj7n commented 1 year ago

I have the same issue with Next 13.1 and React 18.2, looks like the plugin (which did a great job so far) is aging and requires a lifting. How could I fix this with Hooks @dangquanghuy ?

dangquanghuy commented 1 year ago

@c7nj7n: turn off StrictMode

c7nj7n commented 1 year ago

Thank you for your response @dangquanghuy ! If I understand correctly, strict mode is only active on the dev environment in Next.js, hence there should not be an issue on production?

dangquanghuy commented 1 year ago

@c7nj7n : you're welcome. Yes only issue with dev.

FedeMadoery commented 1 year ago

Hey guys! Is there any chance this is fixed on a PR with the provided code? I would love to keep using StrictMode on Nextjs

1finedev commented 4 weeks ago

+1

deback commented 2 weeks ago

+1