From 728c0440d89dc848287654481350685644f254f6 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Mon, 29 Jan 2018 12:27:22 -0800 Subject: [PATCH] updated nav bar to use react router Link --- react/components/AboutPage/index.js | 2 +- react/containers/NavBar/view.jsx | 13 +++++++------ react/root.js | 12 ++++++++---- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/react/components/AboutPage/index.js b/react/components/AboutPage/index.js index 260942e7..5ce194bf 100644 --- a/react/components/AboutPage/index.js +++ b/react/components/AboutPage/index.js @@ -6,7 +6,7 @@ class AboutPage extends React.Component { return (
-

About page

; +

About page

); } diff --git a/react/containers/NavBar/view.jsx b/react/containers/NavBar/view.jsx index 2ecf395f..5f76c61e 100644 --- a/react/containers/NavBar/view.jsx +++ b/react/containers/NavBar/view.jsx @@ -1,7 +1,8 @@ import React from 'react'; -import request from 'utils/request'; +import { Link, withRouter } from 'react-router-dom'; import Logo from 'components/Logo'; import NavBarChannelDropdown from 'components/NavBarChannelOptionsDropdown'; +import request from 'utils/request'; const VIEW = 'VIEW'; const LOGOUT = 'LOGOUT'; @@ -48,7 +49,7 @@ class NavBar extends React.Component { break; case VIEW: // redirect to channel page - window.location.href = `/${this.props.channelName}:${this.props.channelLongId}`; + this.props.history.push(`/${this.props.channelName}:${this.props.channelLongId}`); break; default: break; @@ -63,8 +64,8 @@ class NavBar extends React.Component { Open-source, decentralized image and video sharing.
- Publish - About + Publish + About { this.props.channelName ? ( ) : ( - Channel + Channel )}
@@ -82,4 +83,4 @@ class NavBar extends React.Component { } } -export default NavBar; +export default withRouter(NavBar); diff --git a/react/root.js b/react/root.js index 2d6630ca..0863c664 100644 --- a/react/root.js +++ b/react/root.js @@ -1,7 +1,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { Provider } from 'react-redux'; -import { BrowserRouter as Router, Route } from 'react-router-dom'; +import { BrowserRouter, Route, Switch } from 'react-router-dom'; import PublishPage from 'components/PublishPage'; import AboutPage from 'components/AboutPage'; @@ -9,9 +9,13 @@ import LoginPage from 'components/LoginPage'; const Root = ({ store }) => ( - - - + + + + + + + )