Git Product home page Git Product logo

Comments (5)

thomasMary avatar thomasMary commented on August 17, 2024 5

@ollija Could you push a new version to npm please

from react-native-sortable-grid.

braco avatar braco commented on August 17, 2024 1

Hi @ollija, rn-sg only seems to be tracking children through this.items and _saveItemOrder(), which does not have any update mechanism. It's more of an "add unknown children" method to go along with _removeDisappearedChildren.

You could include updates by altering _saveItemOrder as follows:

  _saveItemOrder = (items) => {
    items.forEach((item, index) => {
      const foundKey = _.findKey(this.itemOrder, oldItem => oldItem.key === item.key);
      if (foundKey) {
        this.items[foundKey] = item;
      }
      else {
        this.itemOrder.push({ key: item.key, ref: item.ref, order: this.items.length });
        if (!this.initialLayoutDone) {
          this.items.push(item);
        }
        ...

but IMO it would be better to stay closer to convention and order/wrap children in render with React.children.map and this.props.children.sort, or something to that effect.

from react-native-sortable-grid.

reimertz avatar reimertz commented on August 17, 2024 1

I have spent maybe 3 hours trying to figure out what the fux I was doing which resulted in a lot of code being refactored into better looking code trying to solve it.

But I hit a brick wall and finally realized that maybe this module doesn't update children and here we are. :D

from react-native-sortable-grid.

alex-paterson avatar alex-paterson commented on August 17, 2024

Yeah, this threw me off. Very necessary update.

from react-native-sortable-grid.

brycepavey avatar brycepavey commented on August 17, 2024

also caught out by this, @ollija could you push an npm version?

from react-native-sortable-grid.

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.