diff options
author | Vitaly Takmazov | 2018-06-09 15:50:47 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2023-01-13 10:37:52 +0300 |
commit | 733343545f2be35f192011f2741dc8c41948cac8 (patch) | |
tree | ba1d4fef36529965b1344f2016e312ad2269816a /vnext/src/components/Discover.js | |
parent | 4e744b4ac064133d36f75799139607508e1cb8d1 (diff) |
many updates
Diffstat (limited to 'vnext/src/components/Discover.js')
-rw-r--r-- | vnext/src/components/Discover.js | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/vnext/src/components/Discover.js b/vnext/src/components/Discover.js index 7fde3d88..63a0cad0 100644 --- a/vnext/src/components/Discover.js +++ b/vnext/src/components/Discover.js @@ -1,30 +1,25 @@ -import "whatwg-fetch" -import React from "react" -import PropTypes from "prop-types" -import queryString from "query-string" +import 'whatwg-fetch'; +import React from 'react'; +import PropTypes from 'prop-types'; +import queryString from 'query-string'; -import Message from "./Message" +import Message from './Message'; export default class Discover extends React.Component { constructor(props) { - super(props) + super(props); this.state = { msgs: [], loading: false, search: this.props.location.search - } + }; this.loadMessages = this.loadMessages.bind(this); } componentDidMount() { this.loadMessages(); } - componentWillReceiveProps(props) { - if (props.params != this.props.params) { - this.loadMessages(); - } - } loadMessages() { - const url = "https://api.juick.com/messages" + this.state.search; + const url = 'https://api.juick.com/messages' + this.state.search; fetch(url) .then(response => { return response.json() @@ -32,20 +27,20 @@ export default class Discover extends React.Component { .then(data => this.setState({ msgs: data }) ).catch(ex => { - console.log(ex) + console.log(ex); }); } - render() { + render() { var nodes = this.state.msgs.map(msg => { - return (<Message key={msg.mid} data={msg}/>) - }); + return (<Message key={msg.mid} data={msg}/>); + }); return ( <div className="msgs" id="content">{nodes}</div> - ) + ); } -}; +} Discover.propTypes = { msgs: PropTypes.array -} +}; |