I try to apply Styled Components to my React code with TypeScript.
Now my render()
method generates multiple elements with loop, and each element's className is generated dynamically by another method.
render() {
try {
const {steps} = this.props;
return (
<div className="step-bar">
{steps.map((s, i) => (
<div key={i} className={this.getClassName(i)}>
{s}
</div>
))}
</div>
);
} catch(e) {
utils.sendErrorObject(e);
return null;
}
};
Now I want to apply Styled Component to this code and handle multiple styles according to className
, but I don't know how to specify the condition because className
is dynamic in the code.
Anyone knows good idea?