Render class import with constructor conditionally

This commit is contained in:
ahocevar
2018-05-20 14:33:40 +02:00
committed by Tim Schaub
parent a224e51c3f
commit a7d180047a

View File

@@ -82,15 +82,22 @@ class Docs extends Component {
);
}
renderConstructor(cls, mod) {
if (cls in mod.classes && cls in mod.classes[cls]) {
return (
<div>
<p>{this.renderImport(cls, mod)}</p>
<h4>new {getName(cls)}()</h4>
</div>
);
}
}
renderClass(cls, mod) {
return cls in mod.classes && cls in mod.classes[cls] ? (
<div key={cls}>
<p>{this.renderImport(cls, mod)}</p>
<h3>new {getName(cls)}()</h3>
</div>
) : (
return (
<div key={cls}>
<h3>{getName(cls)}</h3>
{this.renderConstructor(cls, mod)}
</div>
);
}