From 185af998262b3c33ee55aee87a89d9a5948110b1 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 13 Feb 2018 16:20:54 +0300 Subject: basic navigation --- vnext/src/app.js | 49 +++++++++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 26 deletions(-) (limited to 'vnext/src/app.js') 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 () - }); - return (
{nodes}
) + render() { + return ( +
+ + +
+ ) + } + 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(, document.getElementById("content")); + +ReactDOM.render(, document.getElementById("wrapper")); -- cgit v1.2.3