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

Implement React [email protected] #393

Merged
merged 58 commits into from
Sep 3, 2017
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
19046a0
removed react-router form package.json & installed react-router-dom.
TobiahRex Mar 16, 2017
24d5343
completed index.src refactor.
TobiahRex Mar 16, 2017
441faac
re-implemented App.js
TobiahRex Mar 16, 2017
5c3c6c2
added notes to import changes & App.js
TobiahRex Mar 16, 2017
d3e51e2
modified middleware array @ store/configureStore.js
TobiahRex Mar 22, 2017
c75ff80
updated yarn.lock file with fresh `yarn` command.
TobiahRex Apr 1, 2017
ce00c61
updated master branch.
TobiahRex Apr 2, 2017
b761625
1) updated PR from re-based master. 2) Updated yarn.lock
TobiahRex Apr 2, 2017
8fa5ca5
upgraded react-hot-reloader to @3.0.0-beta.6
TobiahRex Apr 2, 2017
558727d
removed extra "document.getElementById(app) from Root.js
TobiahRex Apr 3, 2017
164b862
moved react-router-redux to regular "dependencies" from "dev-dependen…
TobiahRex Apr 3, 2017
694ddac
cleaned Root.propTypes.
TobiahRex Apr 3, 2017
3e2cfc5
cleaned Root.js & App.js per @oshalygin feedback.
TobiahRex Apr 3, 2017
5667b09
replaced .gitignore comment.
TobiahRex Apr 3, 2017
180e669
removed react-router form package.json & installed react-router-dom.
TobiahRex Mar 16, 2017
2e5ce1d
completed index.src refactor.
TobiahRex Mar 16, 2017
33e87de
re-implemented App.js
TobiahRex Mar 16, 2017
a194252
added notes to import changes & App.js
TobiahRex Mar 16, 2017
a1b920e
Update FAQ.md
kwelch Mar 21, 2017
c91dea4
Update README.md
kwelch Mar 21, 2017
b8fa9ad
modified middleware array @ store/configureStore.js
TobiahRex Mar 22, 2017
82f1ee4
Add react hot loader 3 (#392)
oshalygin Mar 30, 2017
70c1d9c
Updated react-hot-loader to correct package version. (#401)
danielcampo Mar 30, 2017
578176d
Add item to check if issues
coryhouse Mar 30, 2017
aa1fb15
updated yarn.lock file with fresh `yarn` command.
TobiahRex Apr 1, 2017
707e12a
Fix formatting (#403)
kfrn Apr 1, 2017
a2b6bca
updated master branch.
TobiahRex Apr 2, 2017
2e2d60d
upgraded react-hot-reloader to @3.0.0-beta.6
TobiahRex Apr 2, 2017
407144e
removed extra "document.getElementById(app) from Root.js
TobiahRex Apr 3, 2017
3f56197
moved react-router-redux to regular "dependencies" from "dev-dependen…
TobiahRex Apr 3, 2017
a5ef8d2
cleaned Root.js & App.js per @oshalygin feedback.
TobiahRex Apr 3, 2017
c6609c0
replaced .gitignore comment.
TobiahRex Apr 3, 2017
1e72aaa
rebased master. Remove "PropTypes" import from "react" to "prop-types…
TobiahRex Jun 8, 2017
3fc6175
clean index.js
TobiahRex Jun 8, 2017
ab0e2a3
rebasing from upstream master.
TobiahRex Jun 8, 2017
408632f
Merge branch 'master' into [email protected]/tobiahrex
TobiahRex Jun 8, 2017
46b7d26
Add CONTRIBUTE.md (#431)
coryhouse Jul 2, 2017
27169b3
Upgrade to webpack 3
egdelwonk Jul 10, 2017
c35174f
Update yarn lock
coryhouse Jul 12, 2017
f651fc5
Update snapshot
coryhouse Jul 12, 2017
057033a
Merge branch 'egdelwonk-webpack3'
coryhouse Jul 12, 2017
bd13289
Set prod env when analyzing bundle
coryhouse Jul 17, 2017
a5cf0e0
Add jest-cli as dependency
coryhouse Jul 18, 2017
26387b8
Revert PR #450 (#451)
Jul 18, 2017
8ad2d6e
Issue #449 fix (#450)
Aug 7, 2017
57a54e7
Enhance babel env config to transpile for IE9+ (#452)
coryhouse Aug 7, 2017
e0a8524
Fix for jest handling of static assets when running tests. See: (#457)
raythree Aug 15, 2017
8d68161
Added tips for npm run lint and build errors (#151) (#460)
romarioraffington Aug 21, 2017
e7c9c3f
pushing changes from upstream fetch.
TobiahRex Aug 31, 2017
95e6c48
Merge branch 'master' into [email protected]/tobiahrex
TobiahRex Aug 31, 2017
e665193
updated from rebase.
TobiahRex Aug 31, 2017
c155977
Merge branch 'master' into [email protected]/tobiahrex
TobiahRex Aug 31, 2017
d94c0ee
modified package versions in package.json & created new build.
TobiahRex Aug 31, 2017
fb0902d
update package.json
TobiahRex Aug 31, 2017
d116756
fixed conflicts with upstream master.
TobiahRex Aug 31, 2017
251fba8
updated conflicts.
TobiahRex Aug 31, 2017
3efc625
cleaned up PropTypes validations - react-router-redux throwing PropTy…
TobiahRex Aug 31, 2017
975fe9e
comment spell check & de-console on Root.js
TobiahRex Sep 1, 2017
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
Empty file added .watchmanconfig
Empty file.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
"react": "15.4.1",
"react-dom": "15.4.1",
"react-redux": "5.0.1",
"react-router": "3.0.0",
"react-router-redux": "4.0.7",
"react-router-dom": "4.0.0",
"react-router-redux": "5.0.0-alpha.3",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels a bit rough to be using an alpha package. Many of us are using this library for projects and these things will inevitably break into beta+

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I'd like to avoid taking on alpha/beta dependencies.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh didn't see this one here still. @TobiahRex, can the RR4 PR use a stable version of react-router-redux?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about replace react-router-redux (which is still in alpha) with connected-react-router ?

"redux": "3.6.0",
"redux-thunk": "2.1.0"
},
Expand Down Expand Up @@ -66,6 +66,7 @@
"eslint-watch": "2.1.14",
"extract-text-webpack-plugin": "^2.1.0",
"file-loader": "0.9.0",
"history": "4.6.0",
"html-webpack-plugin": "2.24.1",
"identity-obj-proxy": "3.0.0",
"jest": "18.1.0",
Expand Down
4 changes: 3 additions & 1 deletion src/components/AboutPage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React from 'react';
import {Link} from 'react-router';

// Link is no longer a part of the 'react-router v4 API'
import { Link } from 'react-router-dom';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which formatting does our linter support? Spacing between {} in imports or none? I can't remember. cc: @kwelch.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, I know I prefer with spaces. I also believe prettier default is with spaces.

import '../styles/about-page.css';

// Since this component is simple and static, there's no parent container for it.
Expand Down
33 changes: 25 additions & 8 deletions src/components/App.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,37 @@
import React, { PropTypes } from 'react';
import { Link, IndexLink } from 'react-router';
import { Route } from 'react-router';
import { Switch, NavLink } from 'react-router-dom';
// 'Switch' & 'NavLink' imports have moved from the 'react-router' API to 'react-router-dom' since rrV4;
// Also, IndexLink is replaced by NavLink with the activeStyle attr.
// Switch is required for NotFoundPage to be the last case scenario.

import HomePage from './HomePage';
import FuelSavingsPage from '../containers/FuelSavingsPage'; // eslint-disable-line import/no-named-as-default
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider removing this eslint-disable, your code meets the import/no-named-as-default rule afaict.

import AboutPage from './AboutPage';
import NotFoundPage from './NotFoundPage';

// This is a class-based component because the current
// version of hot reloading won't hot reload a stateless
// component at the top-level.

class App extends React.Component {
render() {
const activeStyle = { color: 'blue' };
return (
<div>
<IndexLink to="/">Home</IndexLink>
{' | '}
<Link to="/fuel-savings">Demo App</Link>
{' | '}
<Link to="/about">About</Link>
<br/>
{this.props.children}
<div>
<NavLink exact to="/" activeStyle={activeStyle}>Home</NavLink>
{' | '}
<NavLink to="/fuel-savings" activeStyle={activeStyle}>Demo App</NavLink>
{' | '}
<NavLink to="/about" activeStyle={activeStyle}>About</NavLink>
</div>
<Switch>
<Route exact path="/" component={HomePage} />
<Route path="/fuel-savings" component={FuelSavingsPage} />
<Route path="/about" component={AboutPage} />
<Route component={NotFoundPage} />
</Switch>
</div>
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/HomePage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import {Link} from 'react-router';
import { Link } from 'react-router-dom';

const HomePage = () => {
return (
Expand All @@ -8,7 +8,7 @@ const HomePage = () => {

<h2>Get Started</h2>
<ol>
<li>Review the <Link to="fuel-savings">demo app</Link></li>
<li>Review the <Link to="/fuel-savings">demo app</Link></li>
<li>Remove the demo and start coding: npm run remove-demo</li>
</ol>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/NotFoundPage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Link } from 'react-router';
import { Link } from 'react-router-dom';

const NotFoundPage = () => {
return (
Expand Down
16 changes: 8 additions & 8 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
import React from 'react';
import {render} from 'react-dom';
import { Provider } from 'react-redux';
import { Router, browserHistory } from 'react-router';
import routes from './routes';
import configureStore from './store/configureStore';
import { ConnectedRouter } from 'react-router-redux';

// importing 'history' since it must be the same instance as that passed to redux middleware.
import configureStore, { history } from './store/configureStore';
require('./favicon.ico'); // Tell webpack to load favicon.ico
import './styles/styles.scss'; // Yep, that's right. You can import SASS/CSS files too! Webpack will run the associated loader and plug this into the page.
import { syncHistoryWithStore } from 'react-router-redux';
import App from './components/App';

const store = configureStore();

// Create an enhanced history that syncs navigation events with the store
const history = syncHistoryWithStore(browserHistory, store);

render(
<Provider store={store}>
<Router history={history} routes={routes} />
<ConnectedRouter history={history}>
<App />
</ConnectedRouter>
</Provider>, document.getElementById('app')
);
2 changes: 1 addition & 1 deletion src/reducers/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { combineReducers } from 'redux';
import fuelSavings from './fuelSavingsReducer';
import {routerReducer} from 'react-router-redux';
import { routerReducer } from 'react-router-redux';

const rootReducer = combineReducers({
fuelSavings,
Expand Down
13 changes: 11 additions & 2 deletions src/store/configureStore.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import {createStore, compose, applyMiddleware} from 'redux';
import reduxImmutableStateInvariant from 'redux-immutable-state-invariant';
import thunk from 'redux-thunk';
import createHistory from 'history/createBrowserHistory';
// 'routerMiddleware': the new way of storing route changes with redux middlware since rrV4.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing "e" in middleware

import { routerMiddleware } from 'react-router-redux';
import rootReducer from '../reducers';

export const history = createHistory();
function configureStoreProd(initialState) {
const middlewares = [
// Add other middleware on this line...
Expand All @@ -12,6 +15,9 @@ function configureStoreProd(initialState) {
thunk,
];

const reactRouterMiddleware = routerMiddleware(history);
middlewares.push(reactRouterMiddleware);

return createStore(rootReducer, initialState, compose(
applyMiddleware(...middlewares)
)
Expand All @@ -30,6 +36,9 @@ function configureStoreDev(initialState) {
thunk,
];

const reactRouterMiddleware = routerMiddleware(history);
Copy link
Contributor

@oshalygin oshalygin Mar 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't push to the array, instead declare the array below all this and just include it inline.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oshalygin
Fair enough. I'll change it.

middlewares.push(reactRouterMiddleware);

const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose; // add support for Redux dev tools
const store = createStore(rootReducer, initialState, composeEnhancers(
applyMiddleware(...middlewares)
Expand All @@ -49,4 +58,4 @@ function configureStoreDev(initialState) {

const configureStore = process.env.NODE_ENV === 'production' ? configureStoreProd : configureStoreDev;

export default configureStore;
export default configureStore;