#143 handle undefined console messages

This commit is contained in:
Cassie Tarakajian 2016-11-02 19:23:35 -04:00
parent b06fb4cb80
commit d33b6a354f
2 changed files with 21 additions and 5 deletions

View file

@ -58,11 +58,20 @@ class Console extends React.Component {
appendConsoleEvent(consoleEvent) { appendConsoleEvent(consoleEvent) {
const args = consoleEvent.arguments; const args = consoleEvent.arguments;
const method = consoleEvent.method; const method = consoleEvent.method;
const nextChild = ( let nextChild;
if (Object.keys(args).length === 0) {
nextChild = (
<div key={this.children.length} className="preview-console__undefined">
<span key={`${this.children.length}-0`}>{'undefined'}</span>
</div>
);
} else {
nextChild = (
<div key={this.children.length} className={`preview-console__${method}`}> <div key={this.children.length} className={`preview-console__${method}`}>
{Object.keys(args).map((key) => <span key={`${this.children.length}-${key}`}>{args[key]}</span>)} {Object.keys(args).map((key) => <span key={`${this.children.length}-${key}`}>{args[key]}</span>)}
</div> </div>
); );
}
this.children.push(nextChild); this.children.push(nextChild);
} }

View file

@ -25,6 +25,13 @@
flex: 1 0 auto; flex: 1 0 auto;
} }
.preview-console__undefined {
@include themify(){
color: getThemifyVariable('inactive-text-color');
}
flex: 1 0 auto;
}
.preview-console__error { .preview-console__error {
color: $console-error-color; color: $console-error-color;
flex: 1 0 auto; flex: 1 0 auto;