React router #343

Merged
bones7242 merged 96 commits from react-router into master 2018-02-15 08:02:17 +01:00
3 changed files with 16 additions and 11 deletions
Showing only changes of commit 728c0440d8 - Show all commits

View file

@ -6,7 +6,7 @@ class AboutPage extends React.Component {
return ( return (
<div> <div>
<NavBar/> <NavBar/>
<h1>About page</h1>; <h1>About page</h1>
</div> </div>
); );
} }

View file

@ -1,7 +1,8 @@
import React from 'react'; import React from 'react';
import request from 'utils/request'; import { Link, withRouter } from 'react-router-dom';
import Logo from 'components/Logo'; import Logo from 'components/Logo';
import NavBarChannelDropdown from 'components/NavBarChannelOptionsDropdown'; import NavBarChannelDropdown from 'components/NavBarChannelOptionsDropdown';
import request from 'utils/request';
const VIEW = 'VIEW'; const VIEW = 'VIEW';
const LOGOUT = 'LOGOUT'; const LOGOUT = 'LOGOUT';
@ -48,7 +49,7 @@ class NavBar extends React.Component {
break; break;
case VIEW: case VIEW:
// redirect to channel page // redirect to channel page
window.location.href = `/${this.props.channelName}:${this.props.channelLongId}`; this.props.history.push(`/${this.props.channelName}:${this.props.channelLongId}`);
break; break;
default: default:
break; break;
@ -63,8 +64,8 @@ class NavBar extends React.Component {
<span className="nav-bar-tagline">Open-source, decentralized image and video sharing.</span> <span className="nav-bar-tagline">Open-source, decentralized image and video sharing.</span>
</div> </div>
<div className="nav-bar--right"> <div className="nav-bar--right">
<a className="nav-bar-link link--nav-active" href="/">Publish</a> <Link className="nav-bar-link link--nav-active" to="/">Publish</Link>
<a className="nav-bar-link link--nav" href="/about">About</a> <Link className="nav-bar-link link--nav" to="/about">About</Link>
{ this.props.channelName ? ( { this.props.channelName ? (
<NavBarChannelDropdown <NavBarChannelDropdown
channelName={this.props.channelName} channelName={this.props.channelName}
@ -73,7 +74,7 @@ class NavBar extends React.Component {
LOGOUT={LOGOUT} LOGOUT={LOGOUT}
/> />
) : ( ) : (
<a id="nav-bar-login-link" className="nav-bar-link link--nav" href="/login">Channel</a> <Link id="nav-bar-login-link" className="nav-bar-link link--nav" to="/login">Channel</Link>
)} )}
</div> </div>
</div> </div>
@ -82,4 +83,4 @@ class NavBar extends React.Component {
} }
} }
export default NavBar; export default withRouter(NavBar);

View file

@ -1,7 +1,7 @@
neb-b commented 2018-02-05 20:10:19 +01:00 (Migrated from github.com)
Review

Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a Redirect component or just a route with no path prop.

Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a `Redirect` component or just a route with no `path` prop.
neb-b commented 2018-02-05 20:10:19 +01:00 (Migrated from github.com)
Review

Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a Redirect component or just a route with no path prop.

Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a `Redirect` component or just a route with no `path` prop.
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { Provider } from 'react-redux'; import { Provider } from 'react-redux';
import { BrowserRouter as Router, Route } from 'react-router-dom'; import { BrowserRouter, Route, Switch } from 'react-router-dom';
neb-b commented 2018-02-05 20:10:19 +01:00 (Migrated from github.com)
Review

Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a Redirect component or just a route with no path prop.

Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a `Redirect` component or just a route with no `path` prop.
neb-b commented 2018-02-05 20:10:19 +01:00 (Migrated from github.com)
Review

Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a Redirect component or just a route with no path prop.

Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a `Redirect` component or just a route with no `path` prop.
import PublishPage from 'components/PublishPage'; import PublishPage from 'components/PublishPage';
import AboutPage from 'components/AboutPage'; import AboutPage from 'components/AboutPage';
@ -9,9 +9,13 @@ import LoginPage from 'components/LoginPage';
neb-b commented 2018-02-05 20:10:19 +01:00 (Migrated from github.com)
Review

Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a Redirect component or just a route with no path prop.

Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a `Redirect` component or just a route with no `path` prop.
neb-b commented 2018-02-05 20:10:19 +01:00 (Migrated from github.com)
Review

Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a Redirect component or just a route with no path prop.

Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a `Redirect` component or just a route with no `path` prop.
const Root = ({ store }) => ( const Root = ({ store }) => (
<Provider store={store}> <Provider store={store}>
<Router> <BrowserRouter>
neb-b commented 2018-02-05 20:10:19 +01:00 (Migrated from github.com)
Review

Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a Redirect component or just a route with no path prop.

Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a `Redirect` component or just a route with no `path` prop.
neb-b commented 2018-02-05 20:10:19 +01:00 (Migrated from github.com)
Review

Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a Redirect component or just a route with no path prop.

Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a `Redirect` component or just a route with no `path` prop.
<Route exact path="/" component={PublishPage} /> <Switch>
neb-b commented 2018-02-05 20:10:19 +01:00 (Migrated from github.com)
Review

Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a Redirect component or just a route with no path prop.

Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a `Redirect` component or just a route with no `path` prop.
neb-b commented 2018-02-05 20:10:19 +01:00 (Migrated from github.com)
Review

Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a Redirect component or just a route with no path prop.

Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a `Redirect` component or just a route with no `path` prop.
</Router> <Route exact path="/" component={PublishPage} />
neb-b commented 2018-02-05 20:10:19 +01:00 (Migrated from github.com)
Review

Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a Redirect component or just a route with no path prop.

Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a `Redirect` component or just a route with no `path` prop.
neb-b commented 2018-02-05 20:10:19 +01:00 (Migrated from github.com)
Review

Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a Redirect component or just a route with no path prop.

Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a `Redirect` component or just a route with no `path` prop.
<Route exact path="/about" component={AboutPage} />
neb-b commented 2018-02-05 20:10:19 +01:00 (Migrated from github.com)
Review

Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a Redirect component or just a route with no path prop.

Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a `Redirect` component or just a route with no `path` prop.
<Route exact path="/login" component={LoginPage} />
neb-b commented 2018-02-05 20:10:19 +01:00 (Migrated from github.com)
Review

Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a Redirect component or just a route with no path prop.

Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a `Redirect` component or just a route with no `path` prop.
</Switch>
neb-b commented 2018-02-05 20:10:19 +01:00 (Migrated from github.com)
Review

Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a Redirect component or just a route with no path prop.

Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a `Redirect` component or just a route with no `path` prop.
</BrowserRouter>
neb-b commented 2018-02-05 20:10:19 +01:00 (Migrated from github.com)
Review

Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a Redirect component or just a route with no path prop.

Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a `Redirect` component or just a route with no `path` prop.
</Provider> </Provider>
) )

neb-b commented 2018-02-05 20:10:19 +01:00 (Migrated from github.com)
Review

Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a Redirect component or just a route with no path prop.

Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a `Redirect` component or just a route with no `path` prop.
neb-b commented 2018-02-05 20:10:19 +01:00 (Migrated from github.com)
Review

Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a Redirect component or just a route with no path prop.

Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a `Redirect` component or just a route with no `path` prop.