aboutsummaryrefslogtreecommitdiff
path: root/vnext/src/app.js
blob: 1991a14d054cf71940b94bc30364417b92058933 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import React from "react"
import ReactDOM from "react-dom"
import createHistory from 'history/createBrowserHistory';
const history = createHistory();

import Navigation from "./components/Navigation"
import Discover from "./components/Discover"
import Post from "./components/Post"

class App extends React.Component {
  constructor(props) {
    super(props)
    this.navigate = this.navigate.bind(this);
    this.state = {
      location: history.location
    }
  }
  render() {
    return (
      <div className="wrapper">
        <Navigation onNavigate={this.navigate} />
        { location.pathname === "/" &&
        <Discover params={this.state.location.search} /> }
        { location.pathname === "/post" &&
        <Post /> }
      </div>
    )
  }  
  navigate(location) {
    console.log(location);    
    history.push(location);
    this.setState({location: location})
  }

}


ReactDOM.render(<App />, document.getElementById("wrapper"));