From c754cbba643d7ea1e6312c685f4b321ab5efba6b Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sat, 16 Jun 2018 18:19:54 +0300 Subject: Navigation fix --- vnext/src/components/Discover.js | 22 ++++++++++++++++++---- vnext/src/index.js | 8 ++++---- 2 files changed, 22 insertions(+), 8 deletions(-) (limited to 'vnext') diff --git a/vnext/src/components/Discover.js b/vnext/src/components/Discover.js index 63a0cad0..daf2902f 100644 --- a/vnext/src/components/Discover.js +++ b/vnext/src/components/Discover.js @@ -1,9 +1,9 @@ import 'whatwg-fetch'; import React from 'react'; import PropTypes from 'prop-types'; -import queryString from 'query-string'; import Message from './Message'; +import Icon from './Icon'; export default class Discover extends React.Component { constructor(props) { @@ -18,8 +18,14 @@ export default class Discover extends React.Component { componentDidMount() { this.loadMessages(); } - loadMessages() { - const url = 'https://api.juick.com/messages' + this.state.search; + componentWillReceiveProps(nextProps) { + if (this.props.location.search != nextProps.location.search) { + this.loadMessages(nextProps.location.search) + } + } + loadMessages(filter = '') { + this.setState({ msgs: []}) + const url = 'https://api.juick.com/messages' + filter; fetch(url) .then(response => { return response.json() @@ -35,12 +41,20 @@ export default class Discover extends React.Component { var nodes = this.state.msgs.map(msg => { return (); }); - return ( + return this.state.msgs.length > 0 ? (
{nodes}
+ ) : ( +
); } } +const centeredStyle = { + display: 'flex', + justifyContent: 'center', + alignItems: 'center' +} + Discover.propTypes = { msgs: PropTypes.array }; diff --git a/vnext/src/index.js b/vnext/src/index.js index 97431188..88c13ae3 100644 --- a/vnext/src/index.js +++ b/vnext/src/index.js @@ -38,14 +38,14 @@ class App extends React.Component {