question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Updating children props dynamically ignores "0"

See original GitHub issue

I 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:closed
  • Created 6 years ago
  • Comments:30 (22 by maintainers)

github_iconTop GitHub Comments

1reaction
jorgebucarancommented, Nov 4, 2017

@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

💪😄

1reaction
thysultancommented, Oct 19, 2017

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 and setAttribute operations.

Edit:

executes both the setter and setAttribute operations

The order that it executes them in means that it might not show in devtools, i.e if value = 0

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found