Updating children props dynamically ignores "0"
See original GitHub issueI have a Parent component, that takes children components. I want to dynamically add props to each children so I’m adding “index” in a loop. Every child element is supposed to have attributes “index=0”, “index=1” and so on. But the generated DOM’s 1st element doesn’t have the attribute “index=0” while the rest of them have “index=1”, “index=2” and so on.
Below codepen reproduces the issue: https://codepen.io/rajaraodv/pen/aLPWgd
<div>
<h1>raja</h1> <-- notice that the 1st element is missing index="0"
<h2 index="1"> rao</h2>
</div>
Issue Analytics
- State:
- Created 6 years ago
- Comments:30 (22 by maintainers)
Top Results From Across the Web
Prop not updating dynamically - javascript - Stack Overflow
When a button is clicked the 0/1 turns into the opposite value. I need this dynamically updating as in graph_test.s, I am going...
Read more >Children prop gets recreated killing PureComponent ... - GitHub
If it receives different props every time then it's not “the same” on updates. Therefore it makes sense for PureComponent to not skip...
Read more >How passing props to component works in React
Master how to pass props (properties) to components in React with this useful beginner's guide, including demo code.
Read more >Args - Storybook - JS.ORG
Args can be used to dynamically change props, slots, styles, inputs, etc. It allows Storybook and its addons to live edit components.
Read more >Testing Components with children - Testing Angular
Either declare the child Components in the testing Module. This turns the test into an integration test. Or tell Angular to ignore the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@infinnie @rajaraodv Still not published, but both issues (value=0 and undefined) are now fixed in master!
https://github.com/hyperapp/hyperapp/blob/e02342b8f2ede9e655fcef406908ac536f904720/src/app.js#L146-L153
💪😄
Yes, now that i look at how it’s handled here, it probably shouldn’t matter for the mentioned case(unless the logic of setElementProp changes) since app.js#L134-L143 executes both the
setter
andsetAttribute
operations.Edit:
The order that it executes them in means that it might not show in devtools, i.e if
value = 0