Answer the question
In order to leave comments, you need to log in
Dynamic tag and key?
There are a number of tags that are stored in the store, I display them in the component, it requires a key, please tell me how to add ?, and how to add a class to these items?
class Main extends Component {
render() {
return (
<article className="main">
<div className="main-root">
{ this.props.counter.map((item) => React.createElement(`${item.tag}`))}
</div>
<Edit/>
</article>
);
}
}
Answer the question
In order to leave comments, you need to log in
Option using JSX:
class Main extends Component {
render() {
return (
<article className="main">
<div className="main-root">
{this.props.counter.map(({ tag: Tag }, i) => <Tag key={i} />)}
</div>
<Edit/>
</article>
);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question