Comments (12)
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.
from inferno.
Also to update the state it needs to go through this.setState method.
from inferno.
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.
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.
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.
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.
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.
Of course
from inferno.
Of course
Oh I thought we must use only immutable stuff as state entry
from inferno.
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.
Thanks!
from inferno.
Related Issues (20)
- Passing state with a Router link no longer works with inferno-router `8.0.3` HOT 5
- defaultprops-typings.spec.tsx has wrong parameter name
- Saucelabs not running tests with Firefox HOT 2
- Investigate changes to react-router v5-branch HOT 4
- Simple Clock demo does not work anymore HOT 2
- Add implementation type aliases to make types safe application development easier HOT 2
- Types for non synthetic events HOT 1
- Children of a component is not an Array if there is only a single child HOT 6
- inferno-compat missing support for createRoot HOT 1
- [Question] Inferno renders a component incorrectly HOT 7
- Suggestion: Set up Github discussions HOT 4
- Add FF48 and FF84 to the browser support list HOT 9
- Optimization for class components with exactly one state HOT 4
- How to define Component shape using typescript? HOT 6
- What does findDOMNode return? HOT 2
- Convert all inferno tests from JSX to TSX
- Inferno repository should run all tests using ts-plugin-inferno
- Add support for math formula elements HOT 1
- Inferno should support typing component children to specific type
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from inferno.