Skip to content

Commit

Permalink
add logger to package.json and remove duplicate log
Browse files Browse the repository at this point in the history
  • Loading branch information
viankakrisna committed Sep 27, 2017
1 parent b7e45f2 commit b02372d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
15 changes: 6 additions & 9 deletions packages/react-dev-utils/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ const React = require('react');
const ReactDOM = require('react-dom');
const h = React.createElement;

const useLogger = true;
const domId = 'toast';
const id = 'create-react-app-logger';

let dom = document.getElementById(domId);
let dom = document.getElementById(id);

if (!dom) {
dom = document.createElement('div');
dom.id = domId;
dom.id = id;
document.body.appendChild(dom);
}

Expand Down Expand Up @@ -82,9 +81,11 @@ class Logger extends React.Component {
});
}, this.props.timeout);
}

componentWillUnmount() {
clearTimeout(this.timeout);
}

render() {
return h(
'div',
Expand Down Expand Up @@ -128,11 +129,7 @@ function getColor(type) {
}

function render(type, message) {
if (useLogger) {
ReactDOM.render(h(Logger, { type }, message), dom);
} else {
console.log(message);
}
ReactDOM.render(h(Logger, { type }, message), dom);
}

const logger = {
Expand Down
3 changes: 2 additions & 1 deletion packages/react-dev-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"inquirer.js",
"InterpolateHtmlPlugin.js",
"launchEditor.js",
"launchEditorEndpoint.js",
"logger.js",
"noopServiceWorkerMiddleware.js",
"ModuleScopePlugin.js",
"noopServiceWorkerMiddleware.js",
"openBrowser.js",
Expand Down

0 comments on commit b02372d

Please sign in to comment.