Comments (6)
Hey @alicewriteswrongs Thanks for the quick response! I cannot reproduce it outside Carbon lib..I guess it's some bug weird that stencil plays with Carbon.
from stencil.
Hey @will-hu-0, thanks for reporting!
I was just able to confirm that this is a bug using the reproduction you supplied, thanks for taking the time to put that together.
I did find a quick workaround which you might be able to use to get this code working. I changed the <p>
tag to include a key
attribute based on the card description, like so:
{this.dataForUI.map(card => {
console.log(card);
return <dds-card-group-item cta-type="local" href="https://example.com">
<dds-card-heading>{card.heading}</dds-card-heading>
<p key={card.description}>{card.description}</p> {/* This does NOT work */}
{/* <div>{card.description}</div> This works */}
<dds-card-cta-footer slot="footer"></dds-card-cta-footer>
</dds-card-group-item>
})}
here's a diff of it you could apply to the project:
diff --git a/src/components/my-component/my-component.tsx b/src/components/my-component/my-component.tsx
index d75f4d3..ffe894b 100644
--- a/src/components/my-component/my-component.tsx
+++ b/src/components/my-component/my-component.tsx
@@ -55,14 +55,15 @@ export class MyComponent {
</dds-button-group-item>
</dds-button-group>
<dds-card-group grid-mode="narrow" cards-per-row="3">
- {this.dataForUI.map(card => (
- <dds-card-group-item cta-type="local" href="https://example.com">
+ {this.dataForUI.map(card => {
+ console.log(card);
+ return <dds-card-group-item cta-type="local" href="https://example.com">
<dds-card-heading>{card.heading}</dds-card-heading>
- <p>{card.description}</p> {/* This does NOT work */}
+ <p key={card.description}>{card.description}</p> {/* This does NOT work */}
{/* <div>{card.description}</div> This works */}
<dds-card-cta-footer slot="footer"></dds-card-cta-footer>
</dds-card-group-item>
- ))}
+ })}
</dds-card-group>
</div>
</Host>
I'm going to label this so it gets ingested and the team will investigate and try to come up with a fix.
Thanks again for reporting!
from stencil.
Hey @will-hu-0 I've actually tried to reproduce this without the carbon components and I don't think I'm able to - if I make the following changes to the component in your reproduction case I don't see the issue anymore:
render() {
return (
<Host>
<button onClick={() => this.handleNext()}>
Next
</button>
<div>
{this.dataForUI.map(card => (
<p>{card.description}</p>
))}
</div>
</Host>
)
}
Have you been able to reproduce the issue using only Stencil? We're not able to offer support for issues that crop up in third-party libraries unfortunately
from stencil.
Alright, thanks for getting back! In that case I'm going to close this for now, feel free to open another issue if you do narrow the problem down to a Stencil-only reproduction case.
Thanks!
from stencil.
@will-hu-0 I can see that the issue is already closed, but I think it's important to clarify something.
The problem is that the key
attribute is missing from the dds-card-group-item
element.
The key
is an important element in JSX, and must be unique to each element in the list (it's not advisable to use the index of an array).
from stencil.
@Sukaato fwiw Stencil has an automatic key insertion capability but there might be situations where this doesn't work as expected. If you experience a situation like this and can create a reproducible example, we are happy to look into this.
from stencil.
Related Issues (20)
- bug: cannot get value of inherited custom CSS prop in a shadow DOM element via `E2EElement` APIs HOT 2
- cannot identified the prompts.js as a function?? HOT 17
- bug: generated filename is too long HOT 3
- bug: missing root element's scope id as classname in nested child HOT 4
- bug: Failing to load a nested component hides all parents HOT 1
- bug: child input element is receiving un-wanted props HOT 11
- bug: watchIgnoredRegex is not respected during `stencil build --watch`
- bug: puppeteer: piercing on level 1 breaks HOT 8
- bug: `autofocus` prop/attr is defined on other HTML attribute types instead of `HTMLAttributes` HOT 2
- bug: missing root element's scope id as classname in user provided children HOT 2
- Attribute ping is missing on AnchorHTMLAttributes HOT 3
- bug: Cannot read properties of undefined (reading 'isProxied') HOT 2
- bug: Stencil v4.18.1 breaks support for Jest v26 HOT 10
- bug: intermediate parents' scope ids are not reflected to the children elements HOT 3
- bug: Removing polyfills except for es5 builds breaks existing installs HOT 10
- bug: __mocks__ copied to output target HOT 3
- bug: Cannot access uninitialized variable, only in Safari, works with dev build HOT 3
- bug: Last version 4.18.2 breaks unit test in the proyect. HOT 4
- bug: Test files copied to output target HOT 6
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 stencil.