From a87c3fcaafc8c839ae1263f84502634ef61081ec Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 15 Mar 2018 16:12:24 +0300 Subject: switch to react-router --- vnext/src/app.js | 51 ++++++++++++++++++++++++-------------- vnext/src/components/Navigation.js | 42 ------------------------------- 2 files changed, 32 insertions(+), 61 deletions(-) delete mode 100644 vnext/src/components/Navigation.js (limited to 'vnext/src') diff --git a/vnext/src/app.js b/vnext/src/app.js index 1991a14d0..82209e45b 100644 --- a/vnext/src/app.js +++ b/vnext/src/app.js @@ -1,37 +1,50 @@ import React from "react" import ReactDOM from "react-dom" -import createHistory from 'history/createBrowserHistory'; -const history = createHistory(); +import { BrowserRouter as Router, Route, Link } from "react-router-dom" -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); + super(props); this.state = { - location: history.location + visitor: { uid: 0 } } } render() { return ( -
- - { location.pathname === "/" && - } - { location.pathname === "/post" && - } -
+ +
+
+
+ + + +
+
+ + +
+
) - } - navigate(location) { - console.log(location); - history.push(location); - this.setState({location: location}) } - } diff --git a/vnext/src/components/Navigation.js b/vnext/src/components/Navigation.js deleted file mode 100644 index 95693d81e..000000000 --- a/vnext/src/components/Navigation.js +++ /dev/null @@ -1,42 +0,0 @@ -import React from 'react'; - -export default class Navigation extends React.Component { - constructor(props) { - super(props); - this.state = { - visitor: {uid: 0} - } - this.transition = this.transition.bind(this); - } - transition(event) { - event.preventDefault(); - this.props.onNavigate({ pathname: event.currentTarget.pathname, search: event.currentTarget.search}); - }; - render() { - return ( -
-
- - - -
-
- ) - } -} -- cgit v1.2.3