Answer the question
In order to leave comments, you need to log in
How to render certain markup depending on a condition?
There is such a React component, it changes the markup depending on the condition (in the example, the markup is the same, because I haven’t changed the markup yet), I don’t want to put other markup into a separate component, because in fact, the same data is used and this is one logical part, it makes no sense to take it out.
But I am getting error
https://codepen.io/anon/pen/KboVLm?editors=1010
Answer the question
In order to leave comments, you need to log in
switch(this.props.cardType) {
const Component = components[this.props.cardType];
return Component && <Component {...this.props} />;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question