Coder Social home page Coder Social logo

Comments (10)

ankeetmaini avatar ankeetmaini commented on June 26, 2024 5

Please find a working sample here https://codesandbox.io/s/r7rp40n0zm

Instead of passing the node reference like document.getElementById("some-div") just pass the id of the DOM element.

from react-infinite-scroll-component.

ankeetmaini avatar ankeetmaini commented on June 26, 2024 1

from react-infinite-scroll-component.

ikorgik avatar ikorgik commented on June 26, 2024

Have same problems

from react-infinite-scroll-component.

ankeetmaini avatar ankeetmaini commented on June 26, 2024

I see, I debugged this and seems like by the time your component's render gets called, the element doesn't exist in the DOM. It then passes null, as scrollableTarget, because document.getElementId('some-div') doesn't return anything.

To fix this I'll add another check to see if scrollableTarget's type is string, I'll do a lookup from the DOM inside InfiniteScroll's componentDidMount.

from react-infinite-scroll-component.

gdpsysgarage avatar gdpsysgarage commented on June 26, 2024

@ankeetmaini I have updated the package but when i put the scrollableTarget as a string it breaks all the webapp

<InfiniteScroll
                dataLength={this.props.bills.length}
                next={this.loadBills}
                hasMore={this.state.hasMore}
                scrollableTarget="billList"
                loader={<Loader status={this.props.isFetching} />} >
                  <BillList
                    localId={local.id}
                    token={token}
                    getBills={getBills}
                    openSidebar={this.openSidebar}
                    isSidebarOpen={isSidebarOpen}
                    bills={this.props.bills}
                  />
                </InfiniteScroll>

error

from react-infinite-scroll-component.

ankeetmaini avatar ankeetmaini commented on June 26, 2024

from react-infinite-scroll-component.

gdpsysgarage avatar gdpsysgarage commented on June 26, 2024

Yes

<Grid.Column width={11} id='billList' className='bill-content fdx-content bill-list-container'>
              <InfiniteScroll
                dataLength={this.props.bills.length} //This is important field to render the next data
                next={this.loadBills}
                scrollableTarget="billList"
                hasMore={this.state.hasMore}
                loader={<Loader status={this.props.isFetching} />}>
                  <BillList
                    localId={local.id}
                    token={token}
                    getBills={getBills}
                    openSidebar={this.openSidebar}
                    isSidebarOpen={isSidebarOpen}
                    bills={this.props.bills}
                  />
                </InfiniteScroll>
            </Grid.Column>

from react-infinite-scroll-component.

gdpsysgarage avatar gdpsysgarage commented on June 26, 2024

Yes you are right. If I put the ID in a Grid element it doesnt works. But if I change it to a div it works. Thanks for your work 🥇

from react-infinite-scroll-component.

Linch1 avatar Linch1 commented on June 26, 2024

Hello thanks for this plugin, i have a question.

what if the infinite-scroll-component is rendered inside a shadow dom and also the scollableTarget is in the shadow dom?

If the id of the scollableTarget is passed then the id is relative to the shadow dom and not the main document, so calling document.getElementById("Myid") will result in null, instead if done inside the shadow dom the element is found.

there is a way to pass a ref to the component instead than the id, on an html element ?

from react-infinite-scroll-component.

iwgyyyy avatar iwgyyyy commented on June 26, 2024

Hello thanks for this plugin, i have a question.

what if the infinite-scroll-component is rendered inside a shadow dom and also the scollableTarget is in the shadow dom?

If the id of the scollableTarget is passed then the id is relative to the shadow dom and not the main document, so calling document.getElementById("Myid") will result in null, instead if done inside the shadow dom the element is found.

there is a way to pass a ref to the component instead than the id, on an html element ?

In fact, you can copy the component into your code and then replace document.getElementById with your own code.

from react-infinite-scroll-component.

Related Issues (20)

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.