GithubHelp home page GithubHelp logo

Comments (4)

developerdizzle avatar developerdizzle commented on July 25, 2024 1

No need to apologize! I've started a list of best practices, which includes this slice technique, here #45

from react-virtual-list.

developerdizzle avatar developerdizzle commented on July 25, 2024

Main script will be fixed in the next release! I'll look into supporting mobx lists (possibly a shape with map).

Edit: please see version 2.2.0

from react-virtual-list.

developerdizzle avatar developerdizzle commented on July 25, 2024

I have no experience with mobx, but after doing some quick research, it looks like there are may be two options:

Change

PropTypes.array.isRequired

to

PropTypes.shape({
  map: PropTypes.func.isRequired,
  length: PropTypes.number.isRequired,
})

or

Instruct mobx users to use slice on their arrays before using them in this component. From the mobx documentation on arrays:

Bear in mind however that Array.isArray(observable([])) will yield false, so whenever you need to pass an observable array to an external library, it is a good idea to create a shallow copy before passing it to other libraries or built-in functions (which is good practice anyway) by using array.slice(). In other words, Array.isArray(observable([]).slice()) will yield true.

@uinz - as a mobx dev, do you have any thoughts on which makes more sense?

from react-virtual-list.

uinz avatar uinz commented on July 25, 2024

@developerdizzle

sorry, I am unskilled with mobx

I think use .slice() to avoid type inspection error is the right way

from react-virtual-list.

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.