aboutsummaryrefslogtreecommitdiff
path: root/vnext/src/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'vnext/src/app.js')
-rw-r--r--vnext/src/app.js49
1 files changed, 23 insertions, 26 deletions
diff --git a/vnext/src/app.js b/vnext/src/app.js
index ba5ce816..fed735f7 100644
--- a/vnext/src/app.js
+++ b/vnext/src/app.js
@@ -1,37 +1,34 @@
-import "whatwg-fetch"
import React from "react"
-import PropTypes from "prop-types"
import ReactDOM from "react-dom"
+import createHistory from 'history/createBrowserHistory';
+const history = createHistory();
-import Message from "./components/Message"
+import Navigation from "./components/Navigation"
+import Discover from "./components/Discover"
-class Page extends React.Component {
+class App extends React.Component {
constructor(props) {
super(props)
- this.state = {msgs: [], loading: false}
+ this.navigate = this.navigate.bind(this);
+ this.state = {
+ location: history.location
+ }
}
- render() {
- var nodes = this.state.msgs.map(msg => {
- return (<Message key={msg.mid} data={msg}/>)
- });
- return (<div className="msgs">{nodes}</div>)
+ render() {
+ return (
+ <div className="wrapper">
+ <Navigation onNavigate={this.navigate} />
+ <Discover params={this.state.location.search} />
+ </div>
+ )
+ }
+ navigate(location) {
+ console.log(location);
+ history.push(location);
+ this.setState({location: location})
}
- componentDidMount() {
- fetch(this.props.source)
- .then(response => {
- return response.json()
- })
- .then(data =>
- this.setState({ msgs: data })
- ).catch(ex => {
- console.log(ex)
- });
- }
-};
-Page.propTypes = {
- msgs: PropTypes.array,
- source: PropTypes.string.isRequired
}
-ReactDOM.render(<Page source="https://api.juick.com/messages" />, document.getElementById("content"));
+
+ReactDOM.render(<App />, document.getElementById("wrapper"));