import * as Actions from '../actions'; import React from 'react'; import TabbedSqlEditors from './TabbedSqlEditors'; import QueryAutoRefresh from './QueryAutoRefresh'; import QuerySearch from './QuerySearch'; import Alerts from './Alerts'; import { bindActionCreators } from 'redux'; import { connect } from 'react-redux'; class App extends React.PureComponent { constructor(props) { super(props); this.state = { hash: window.location.hash, }; } componentDidMount() { window.addEventListener('hashchange', this.onHashChanged.bind(this)); } componentWillUnmount() { window.removeEventListener('hashchange', this.onHashChanged.bind(this)); } onHashChanged() { this.setState({ hash: window.location.hash }); } render() { let content; if (this.state.hash) { content = (
); } else { content = (
); } return (
{content}
); } } App.propTypes = { alerts: React.PropTypes.array, actions: React.PropTypes.object, }; function mapStateToProps(state) { return { alerts: state.alerts, }; } function mapDispatchToProps(dispatch) { return { actions: bindActionCreators(Actions, dispatch), }; } export { App }; export default connect(mapStateToProps, mapDispatchToProps)(App);