GithubHelp home page GithubHelp logo

Comments (12)

Havunen avatar Havunen commented on June 7, 2024

Did you change the whole component state object to be an array? That is not supported, you should instead have state as an object and have a property pointing to the array. Something like this:

this.state = { data: theArray };

from inferno.

farooqkz avatar farooqkz commented on June 7, 2024

from inferno.

Havunen avatar Havunen commented on June 7, 2024

Also to update the state it needs to go through this.setState method.

from inferno.

farooqkz avatar farooqkz commented on June 7, 2024

Yeah I do that. But Inferno won't detect change in an array. right? That's my problem. How about storing the array in this and number of elements in state? Do you think it's a good idea?

from inferno.

Havunen avatar Havunen commented on June 7, 2024

Yeah I do that. But Inferno won't detect change in an array. right?

I don't fully understand what you mean by detecting the change? Having state object as an array is not supported, it should be object with key value pairs where the value can be array.

As long as the render method of your component returns with a new set of elements Inferno will change the DOM accordingly

Have you checked that you don't have shouldComponentUpdate somewhere preventing the update?

from inferno.

farooqkz avatar farooqkz commented on June 7, 2024

Yeah I do that. But Inferno won't detect change in an array. right?

I don't fully understand what you mean by detecting the change? Having state object as an array is not supported, it should be object with key value pairs where the value can be array.

As long as the render method of your component returns with a new set of elements Inferno will change the DOM accordingly

Have you checked that you don't have shouldComponentUpdate somewhere preventing the update?

I have an array as this.state.data and I update data

from inferno.

Havunen avatar Havunen commented on June 7, 2024

There is always "this.forceUpdate" method but I doubt it solves your problem, I believe there is something else going wrong at the application level

from inferno.

farooqkz avatar farooqkz commented on June 7, 2024

Does Inferno re-render if one of state entries is an Array and it gets changed.

E.g.

state = {
  data: [1,2,3],
} // before
state = {
  data: [1, 2, 3, 4],
} // after

from inferno.

Havunen avatar Havunen commented on June 7, 2024

Of course

from inferno.

farooqkz avatar farooqkz commented on June 7, 2024

Of course

Oh I thought we must use only immutable stuff as state entry

from inferno.

Havunen avatar Havunen commented on June 7, 2024

As long as the state object itself is new one, then its up to the render method of application to handle it correctly to create new vNodes

from inferno.

farooqkz avatar farooqkz commented on June 7, 2024

Thanks!

from inferno.

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.