Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(router): using react-router@4.0.0-alpha.5 #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"highlight.js": "^9.7.0",
"react": "^15.3.2",
"react-dom": "^15.3.2",
"react-router": "^2.8.1",
"react-router": "4.0.0-alpha.5",
"react-syntax-highlight": "^0.0.2",
"sw-precache": "^4.1.0"
},
Expand Down
21 changes: 20 additions & 1 deletion src/App.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import React, { Component } from 'react';
import { Match, Miss, Redirect } from 'react-router'
import Menu from './Menu';
import Header from './Header';
import Introduction from './step-1/Introduction';
import Setup from './step-2/Setup';
import AppShell from './step-3/AppShell';
import ServiceWorker from './step-4/ServiceWorker';
import Offline from './step-5/Offline';
import AppLike from './step-6/AppLike';
import Finish from './step-7/Finish';
import PageNotFound from './PageNotFound';
import GitHub from './GitHub.png';

class App extends Component {
Expand Down Expand Up @@ -28,7 +37,17 @@ class App extends Component {
<a className="app__source-link" title="Source" href="https://github.com/code-kotis/pwa-codelabs" target="_blank" rel="noopener">
<img className="app__source" alt="Source" src={GitHub} />
</a>
{this.props.children}

<Match pattern="/" exactly render={() => <Redirect to="/introduction"/> }/>
<Match pattern="/introduction" component={Introduction} />
<Match pattern="/setup" component={Setup} />
<Match pattern="/appshell" component={AppShell} />
<Match pattern="/serviceworker" component={ServiceWorker} />
<Match pattern="/offline" component={Offline} />
<Match pattern="/applike" component={AppLike} />
<Match pattern="/finish" component={Finish} />

<Miss component={PageNotFound} />
</div>
</div>
);
Expand Down
6 changes: 5 additions & 1 deletion src/App.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter } from 'react-router';
import App from './App';

it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render(<App />, div);
ReactDOM.render(
<BrowserRouter>
<App />
</BrowserRouter>, div);
});
2 changes: 1 addition & 1 deletion src/Menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class Menu extends Component {
</div>
<ul className="menu__list">
<li>
<NavLink to="/introduction" onlyActiveOnIndex={true}>
<NavLink to="/introduction">
<span className="menu__steps">1</span>
Introduction
</NavLink>
Expand Down
27 changes: 4 additions & 23 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,14 @@
import React from 'react';
import ReactDOM from 'react-dom';
import { Router, Route, hashHistory, IndexRoute, IndexRedirect } from 'react-router';
import { BrowserRouter } from 'react-router';
import App from './App';
import Introduction from './step-1/Introduction';
import Setup from './step-2/Setup';
import AppShell from './step-3/AppShell';
import ServiceWorker from './step-4/ServiceWorker';
import Offline from './step-5/Offline';
import AppLike from './step-6/AppLike';
import Finish from './step-7/Finish';
import PageNotFound from './PageNotFound';
import './index.css';
import './App.css';
import './syntax.css';

ReactDOM.render(
<Router history={hashHistory}>
<Route path="/" component={App}>
<IndexRoute component={Introduction} />
<IndexRedirect to="/introduction" />
<Route path="/introduction" component={Introduction} />
<Route path="/setup" component={Setup} />
<Route path="/appshell" component={AppShell} />
<Route path="/serviceworker" component={ServiceWorker} />
<Route path="/offline" component={Offline} />
<Route path="/applike" component={AppLike} />
<Route path="/finish" component={Finish} />
<Route path="*" component={PageNotFound} />
</Route>
</Router>,
<BrowserRouter>
<App />
</BrowserRouter>,
document.getElementById('root')
);
74 changes: 37 additions & 37 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1529,10 +1529,6 @@ decamelize@^1.0.0, decamelize@^1.1.1, decamelize@^1.1.2:
version "1.2.0"
resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290"

deep-equal@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.0.1.tgz#f5d260292b660e084eff4cdbc9f08ad3247448b5"

deep-extend@~0.4.0:
version "0.4.1"
resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.4.1.tgz#efe4113d08085f4e6f9687759810f807469e2253"
Expand Down Expand Up @@ -2408,23 +2404,20 @@ highlight.js@^9.3.0, highlight.js@^9.7.0:
version "9.7.0"
resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-9.7.0.tgz#e7a926bf3079c65b2ae50314878e456a009b4aac"

history@^2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/history/-/history-2.1.2.tgz#4aa2de897a0e4867e4539843be6ecdb2986bfdec"
history@^4.3.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/history/-/history-4.4.0.tgz#b1369588cb9e5d80219d0b1f866b0ac62c14a7f8"
dependencies:
deep-equal "^1.0.0"
invariant "^2.0.0"
query-string "^3.0.0"
warning "^2.0.0"
invariant "^2.2.1"
loose-envify "^1.2.0"
resolve-pathname "^2.0.0"
value-equal "^0.1.1"
warning "^3.0.0"

hoek@2.x.x:
version "2.16.3"
resolved "https://registry.yarnpkg.com/hoek/-/hoek-2.16.3.tgz#20bb7403d3cea398e91dc4710a8ff1b8274a25ed"

hoist-non-react-statics@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-1.2.0.tgz#aa448cf0986d55cc40773b17174b7dd066cb7cfb"

home-or-tmp@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/home-or-tmp/-/home-or-tmp-1.0.0.tgz#4b9f1e40800c3e50c6c27f781676afcce71f3985"
Expand Down Expand Up @@ -2607,7 +2600,7 @@ interpret@^0.6.4:
version "0.6.6"
resolved "https://registry.yarnpkg.com/interpret/-/interpret-0.6.6.tgz#fecd7a18e7ce5ca6abfb953e1f86213a49f1625b"

invariant@^2.0.0, invariant@^2.2.0, invariant@^2.2.1:
invariant@^2.2.0, invariant@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.1.tgz#b097010547668c7e337028ebe816ebe36c8a8d54"
dependencies:
Expand Down Expand Up @@ -3905,6 +3898,12 @@ path-to-regexp@^1.0.1:
dependencies:
isarray "0.0.1"

path-to-regexp@^1.5.3:
version "1.7.0"
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-1.7.0.tgz#59fde0f435badacba103a84e9d3bc64e96b9937d"
dependencies:
isarray "0.0.1"

path-to-regexp@0.1.7:
version "0.1.7"
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.7.tgz#df604178005f522f15eb4490e7247a1bfaa67f8c"
Expand Down Expand Up @@ -4277,13 +4276,7 @@ qs@6.2.0:
version "6.2.0"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.2.0.tgz#3b7848c03c2dece69a9522b0fae8c4126d745f3b"

query-string@^3.0.0:
version "3.0.3"
resolved "https://registry.yarnpkg.com/query-string/-/query-string-3.0.3.tgz#ae2e14b4d05071d4e9b9eb4873c35b0dcd42e638"
dependencies:
strict-uri-encode "^1.0.0"

query-string@^4.1.0:
query-string@^4.1.0, query-string@4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/query-string/-/query-string-4.2.3.tgz#9f27273d207a25a8ee4c7b8c74dcd45d556db822"
dependencies:
Expand Down Expand Up @@ -4322,6 +4315,12 @@ rc@~1.1.0:
minimist "^1.2.0"
strip-json-comments "~1.0.4"

react-broadcast@^0.1.1:
version "0.1.2"
resolved "https://registry.yarnpkg.com/react-broadcast/-/react-broadcast-0.1.2.tgz#950de63578a2af399a396067a617af7402182330"
dependencies:
invariant "^2.2.1"

react-dev-utils@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/react-dev-utils/-/react-dev-utils-0.2.1.tgz#c017d6f530502b28b735dbac3841a7b8665838f5"
Expand All @@ -4338,15 +4337,14 @@ react-dom@^15.0.1, react-dom@^15.3.2:
version "15.3.2"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-15.3.2.tgz#c46b0aa5380d7b838e7a59c4a7beff2ed315531f"

react-router@^2.8.1:
version "2.8.1"
resolved "https://registry.yarnpkg.com/react-router/-/react-router-2.8.1.tgz#73e9491f6ceb316d0f779829081863e378ee4ed7"
react-router@4.0.0-alpha.5:
version "4.0.0-alpha.5"
resolved "https://registry.yarnpkg.com/react-router/-/react-router-4.0.0-alpha.5.tgz#9d80514f9bbbec040dffbd4f9cf241da2830e318"
dependencies:
history "^2.1.2"
hoist-non-react-statics "^1.2.0"
invariant "^2.2.1"
loose-envify "^1.2.0"
warning "^3.0.0"
history "^4.3.0"
path-to-regexp "^1.5.3"
query-string "4.2.3"
react-broadcast "^0.1.1"

react-scripts@0.6.1:
version "0.6.1"
Expand Down Expand Up @@ -4644,6 +4642,10 @@ resolve-from@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-1.0.1.tgz#26cbfe935d1aeeeabb29bc3fe5aeb01e93d44226"

resolve-pathname@^2.0.0:
version "2.0.2"
resolved "https://registry.yarnpkg.com/resolve-pathname/-/resolve-pathname-2.0.2.tgz#e55c016eb2e9df1de98e85002282bfb38c630436"

resolve@^1.1.6, resolve@1.1.7, resolve@1.1.x:
version "1.1.7"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b"
Expand Down Expand Up @@ -5282,6 +5284,10 @@ validate-npm-package-license@^3.0.1:
spdx-correct "~1.0.0"
spdx-expression-parse "~1.0.0"

value-equal@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/value-equal/-/value-equal-0.1.1.tgz#b174df21f203c81e17f2e4d59d3a900024cbef7b"

vary@~1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.0.tgz#e1e5affbbd16ae768dd2674394b9ad3022653140"
Expand All @@ -5308,12 +5314,6 @@ walker@~1.0.5:
dependencies:
makeerror "1.0.x"

warning@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/warning/-/warning-2.1.0.tgz#21220d9c63afc77a8c92111e011af705ce0c6901"
dependencies:
loose-envify "^1.0.0"

warning@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/warning/-/warning-3.0.0.tgz#32e5377cb572de4ab04753bdf8821c01ed605b7c"
Expand Down