From 7284f4bb640e9213b13e978df1fae768bb620e93 Mon Sep 17 00:00:00 2001 From: Noah Loomans Date: Tue, 26 Jun 2018 22:28:33 +0200 Subject: Calculate isVisible in redux --- src/client/react/components/container/HelpBox.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/client/react/components/container') diff --git a/src/client/react/components/container/HelpBox.js b/src/client/react/components/container/HelpBox.js index 6579383..3358a76 100644 --- a/src/client/react/components/container/HelpBox.js +++ b/src/client/react/components/container/HelpBox.js @@ -27,13 +27,13 @@ import './HelpBox.scss'; class HelpBox extends React.Component { static propTypes = { // redux - results: PropTypes.arrayOf(PropTypes.string).isRequired, - searchText: PropTypes.string.isRequired, + isVisible: PropTypes.bool.isRequired, } render() { - const { results, searchText } = this.props; - if (results.length > 0 || searchText !== '') { + const { isVisible } = this.props; + + if (!isVisible) { return
; } @@ -49,8 +49,7 @@ class HelpBox extends React.Component { } const mapStateToProps = state => ({ - results: state.search.results, - searchText: state.search.text, + isVisible: state.search.results.length === 0 && state.search.text === '', }); export default connect(mapStateToProps)(HelpBox); -- cgit v1.1