From db184f9539f772c14de2e83b80211fd0d4e80701 Mon Sep 17 00:00:00 2001 From: Nik Graf Date: Sun, 20 Sep 2015 19:46:02 +0200 Subject: [PATCH] fix(DevTools, LogMonitor): prevent LogMonitor to render once as visible state --- src/createDevTools.js | 19 ++++++++++++++++++- src/react/LogMonitor.js | 15 ++------------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/createDevTools.js b/src/createDevTools.js index b5eecadd..9a50ad48 100644 --- a/src/createDevTools.js +++ b/src/createDevTools.js @@ -10,9 +10,26 @@ export default function createDevTools(React) { ActionCreators ) class DevTools extends Component { + + static defaultProps = { + visibleOnLoad: true + }; + + componentWillMount() { + const monitorState = { + ...this.props.monitorState, + isVisible: this.props.visibleOnLoad + }; + this.props.setMonitorState(monitorState); + } + render() { + const monitorState = { + ...this.props.monitorState, + isVisible: this.props.visibleOnLoad + }; const { monitor: Monitor } = this.props; - return ; + return ; } } diff --git a/src/react/LogMonitor.js b/src/react/LogMonitor.js index d960f460..bce96e72 100644 --- a/src/react/LogMonitor.js +++ b/src/react/LogMonitor.js @@ -53,15 +53,13 @@ export default class LogMonitor extends Component { toggleAction: PropTypes.func.isRequired, jumpToState: PropTypes.func.isRequired, setMonitorState: PropTypes.func.isRequired, - select: PropTypes.func.isRequired, - visibleOnLoad: PropTypes.bool + select: PropTypes.func.isRequired }; static defaultProps = { select: (state) => state, monitorState: { isVisible: true }, - theme: 'nicinabox', - visibleOnLoad: true + theme: 'nicinabox' }; componentWillReceiveProps(nextProps) { @@ -93,15 +91,6 @@ export default class LogMonitor extends Component { } } - componentWillMount() { - let visibleOnLoad = this.props.visibleOnLoad; - const { monitorState } = this.props; - this.props.setMonitorState({ - ...monitorState, - isVisible: visibleOnLoad - }); - } - handleRollback() { this.props.rollback(); }