diff --git a/embark-ui/src/components/ExplorerLayout.js b/embark-ui/src/components/ExplorerLayout.js index 48640c775..0f17806ee 100644 --- a/embark-ui/src/components/ExplorerLayout.js +++ b/embark-ui/src/components/ExplorerLayout.js @@ -15,8 +15,17 @@ import TransactionContainer from '../containers/TransactionContainer'; import SearchBar from '../components/SearchBar'; class ExplorerLayout extends React.Component { + constructor(props) { + super(props); + + this.state = {loading: false}; + } + shouldComponentUpdate(nextProps) { - if (nextProps.searchResult && nextProps.searchResult !== this.props.searchResult) { + if (nextProps.searchResult && Object.keys(nextProps.searchResult).length && + nextProps.searchResult !== this.props.searchResult) { + this.setState({loading: false}); + if (nextProps.searchResult.error) { return true; } @@ -38,11 +47,17 @@ class ExplorerLayout extends React.Component { return true; } + searchTheExplorer(value) { + this.props.explorerSearch(value); + this.setState({loading: true}); + } + render() { - const {explorerSearch, searchResult} = this.props; + const {searchResult} = this.props; return ( - explorerSearch(searchValue)}/> + this.searchTheExplorer(searchValue)}/> + {this.state.loading &&

Searching...

} {searchResult.error && {searchResult.error}}