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

Browser history with api fallback #41

Merged
merged 3 commits into from
Feb 13, 2017
Merged
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
8 changes: 4 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

<head>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="description" content>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>React / Redux / TypeScript - starter-kit</title>
<link rel="stylesheet" href="assets/loader-styles.css">
<link rel="stylesheet" href="https://unpkg.com/[email protected]">
<link href="assets/loader-styles.css" rel="stylesheet">
<link href="https://unpkg.com/[email protected]" rel="stylesheet">
</head>

<body>
Expand Down Expand Up @@ -36,7 +36,7 @@
// hot-reload config
SystemJS.import('systemjs-hot-reloader').then(function(HotReloader) {
// if you're running server on custom port please remember to update below
new HotReloader.default('http://localhost:8888');
new HotReloader.default('http://localhost:3000');
});
// load main module of your app with SystemJS
SystemJS.trace = true;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"husky": "^0.11.8",
"jest": "^17.0.3",
"jspm": "0.17.0-beta.32",
"jspm-hmr": "^0.5.0",
"jspm-hmr": "1.0.0-0",
"regenerator": "^0.9.5",
"shelljs": "^0.7.5",
"shx": "^0.2.1",
Expand Down
21 changes: 19 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
'use strict';
const jspmHmrServer = require('jspm-hmr');

const options = {
open: true
fallback: '/index.html',
verbose: false,
};

jspmHmrServer.start(options);
// SERVER
const server = jspmHmrServer.createServer(options);

server
.listen(3000, (err) => {
console.log('[debug] %j', server.address());
console.log('\n>>> hit CTRL-C twice to exit <<<\n');
})
.on('error', function (err) {
if (err.code === 'EADDRINUSE') {
console.log(`\n[WARNING] Selected address is in use: ${URL}`);
console.log(`[WARNING] Please try again using different port or address...\n`);

process.exit();
}
});
6 changes: 4 additions & 2 deletions src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { Router, Route, hashHistory } from 'react-router';
import { Router, Route, browserHistory } from 'react-router';
import { syncHistoryWithStore } from 'react-router-redux';
// app imports
import { MainLayout } from './layouts/main-layout';
import { HomeContainer } from './containers/home-container/index';
import { CssModulesContainer } from './containers/css-modules-container/index';
import NotFoundContainer from './containers/not-found/index';
import CurrencyConverterContainer from './containers/currency-converter-container/index';

import { store } from './store/index';
const history = syncHistoryWithStore(hashHistory, store) as any;
const history = syncHistoryWithStore(browserHistory, store) as any;

function App() {
return (
Expand All @@ -21,6 +22,7 @@ function App() {
<Route path="/" component={HomeContainer} />
<Route path="/currency-converter" component={CurrencyConverterContainer} />
<Route path="/css-modules" component={CssModulesContainer} />
<Route path="*" component={NotFoundContainer} />
</Route>
</Router>
</Provider>
Expand Down
16 changes: 16 additions & 0 deletions src/containers/not-found/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import * as React from 'react';
import { Link } from 'react-router';
import { PageSection } from '../../components/page-section';
import { PageHero } from '../../components/page-hero';

export default function () {
return (
<article>
<PageHero title="404 Not Found" subtitle="Page not found" />
<PageSection className="o-container o-container--small u-centered">
<Link to="/">Back to Home</Link>
</PageSection>
<br />
</article>
);
};
Loading