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 41 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.
28 changes: 15 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@
"react": "15.5.4",
"react-dom": "15.5.4",
"react-redux": "5.0.5",
"react-router": "3.0.5",
"react-router-redux": "4.0.8",
"react-router": "4.2.0",
"react-router-dom": "4.0.0",
"react-router-redux": "5.0.0-alpha.6",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just want to ask this again before we move forward...

Are we sure we want to keep this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Owner

Choose a reason for hiding this comment

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

I vote for dropping it. Easy to add if desired, and avoids an alpha dep

"redux": "3.6.0",
"redux-thunk": "2.1.0"
},
Expand All @@ -55,18 +56,19 @@
"babel-preset-react-hmre": "1.1.1",
"babel-preset-stage-1": "6.16.0",
"browser-sync": "2.18.5",
"chalk": "1.1.3",
"chalk": "2.0.1",
"connect-history-api-fallback": "1.3.0",
"coveralls": "2.11.15",
"css-loader": "0.26.1",
"enzyme": "2.8.2",
"eslint": "3.12.2",
"eslint-plugin-import": "2.2.0",
"eslint-plugin-react": "6.8.0",
"eslint-watch": "2.1.14",
"extract-text-webpack-plugin": "2.1.0",
"file-loader": "0.9.0",
"html-webpack-plugin": "2.24.1",
"coveralls": "2.13.1",
"css-loader": "0.28.4",
"enzyme": "2.9.1",
"eslint": "4.2.0",
"eslint-plugin-import": "2.7.0",
"eslint-plugin-react": "7.1.0",
"eslint-watch": "3.1.2",
"extract-text-webpack-plugin": "3.0.0-rc.2",
"file-loader": "0.11.2",
"history": "4.6.0",
"html-webpack-plugin": "2.29.0",
"identity-obj-proxy": "3.0.0",
"jest": "18.1.0",
"json-loader": "0.5.4",
Expand Down
2 changes: 1 addition & 1 deletion src/components/AboutPage.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';
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
2 changes: 1 addition & 1 deletion src/components/AboutPage.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import {shallow} from 'enzyme';
import { shallow } from 'enzyme';
Copy link
Collaborator

Choose a reason for hiding this comment

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

same as above.

import AboutPage from './AboutPage';

describe('<AboutPage />', () => {
Expand Down
31 changes: 23 additions & 8 deletions src/components/App.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,36 @@
/* eslint-disable import/no-named-as-default */

import React from 'react';
import PropTypes from 'prop-types';
import { Link, IndexLink } from 'react-router';
import { Route } from 'react-router';
import { Switch, NavLink } from 'react-router-dom';
import HomePage from './HomePage';
import FuelSavingsPage from '../containers/FuelSavingsPage';
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
79 changes: 40 additions & 39 deletions src/components/FuelSavingsForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,48 +32,48 @@ class FuelSavingsForm extends React.Component {
<h2>Fuel Savings Analysis</h2>
<table>
<tbody>
<tr>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nickytonline & @coryhouse
I believe the white spacing change I made here is correct. Should not a <tr> appear as a child of a <tbody> in this case and not a sibling? Please confirm you'd like it to appear as a sibling and I'll revert.

Copy link
Owner

Choose a reason for hiding this comment

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

Point taken. You can leave it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@coryhouse thanks for the confirmation.

<td><label htmlFor="newMpg">New Vehicle MPG</label></td>
<td><FuelSavingsTextInput onChange={this.fuelSavingsKeypress} name="newMpg" value={fuelSavings.newMpg}/>
</td>
</tr>
<tr>
<td><label htmlFor="tradeMpg">Trade-in MPG</label></td>
<td><FuelSavingsTextInput onChange={this.fuelSavingsKeypress} name="tradeMpg" value={fuelSavings.tradeMpg}/>
</td>
</tr>
<tr>
<td><label htmlFor="newPpg">New Vehicle price per gallon</label></td>
<td><FuelSavingsTextInput onChange={this.fuelSavingsKeypress} name="newPpg" value={fuelSavings.newPpg}/>
</td>
</tr>
<tr>
<td><label htmlFor="tradePpg">Trade-in price per gallon</label></td>
<td><FuelSavingsTextInput onChange={this.fuelSavingsKeypress} name="tradePpg" value={fuelSavings.tradePpg}/>
</td>
</tr>
<tr>
<td><label htmlFor="milesDriven">Miles Driven</label></td>
<td>
<FuelSavingsTextInput
<tr>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Once again, question about the spacing changes. Is this our eslint config doing this?

Copy link
Contributor Author

@TobiahRex TobiahRex Aug 31, 2017

Choose a reason for hiding this comment

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

@nickytonline This one looks like its from my text-editor. I use an atom package language-babel to automatically calculate JSX spacing. In this particular case, i think i nudged it over accidentally.

Copy link
Owner

Choose a reason for hiding this comment

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

@TobiahRex - Would you be willing to rollback the whitespace changes in this PR to keep the diff minimal?

Copy link
Contributor Author

@TobiahRex TobiahRex Sep 2, 2017

Choose a reason for hiding this comment

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

@nickytonline & @coryhouse After checking again, i think this is a correct addition of whitespace. The <tr> should appear as a child of <tbody> and not a sibling due to hierarchical precedence, correct? If you'd still like me to revert back to what it was before, i can do that. please confirm.

<td><label htmlFor="newMpg">New Vehicle MPG</label></td>
<td><FuelSavingsTextInput onChange={this.fuelSavingsKeypress} name="newMpg" value={fuelSavings.newMpg}/>
</td>
</tr>
<tr>
<td><label htmlFor="tradeMpg">Trade-in MPG</label></td>
<td><FuelSavingsTextInput onChange={this.fuelSavingsKeypress} name="tradeMpg" value={fuelSavings.tradeMpg}/>
</td>
</tr>
<tr>
<td><label htmlFor="newPpg">New Vehicle price per gallon</label></td>
<td><FuelSavingsTextInput onChange={this.fuelSavingsKeypress} name="newPpg" value={fuelSavings.newPpg}/>
</td>
</tr>
<tr>
<td><label htmlFor="tradePpg">Trade-in price per gallon</label></td>
<td><FuelSavingsTextInput onChange={this.fuelSavingsKeypress} name="tradePpg" value={fuelSavings.tradePpg}/>
</td>
</tr>
<tr>
<td><label htmlFor="milesDriven">Miles Driven</label></td>
<td>
<FuelSavingsTextInput
onChange={this.fuelSavingsKeypress}
name="milesDriven"
value={fuelSavings.milesDriven}/>
miles per
<select
miles per
<select
name="milesDrivenTimeframe"
onChange={this.onTimeframeChange}
value={fuelSavings.milesDrivenTimeframe}>
<option value="week">Week</option>
<option value="month">Month</option>
<option value="year">Year</option>
</select>
</td>
</tr>
<tr>
<td><label>Date Modified</label></td>
<td>{fuelSavings.dateModified}</td>
</tr>
<option value="week">Week</option>
<option value="month">Month</option>
<option value="year">Year</option>
</select>
</td>
</tr>
<tr>
<td><label>Date Modified</label></td>
<td>{fuelSavings.dateModified}</td>
</tr>
</tbody>
</table>

Expand All @@ -85,11 +85,12 @@ class FuelSavingsForm extends React.Component {
);
}
}
const { func, object } = PropTypes;

FuelSavingsForm.propTypes = {
saveFuelSavings: PropTypes.func.isRequired,
calculateFuelSavings: PropTypes.func.isRequired,
fuelSavings: PropTypes.object.isRequired
saveFuelSavings: func.isRequired,
calculateFuelSavings: func.isRequired,
fuelSavings: object.isRequired
};

export default FuelSavingsForm;
6 changes: 3 additions & 3 deletions src/components/FuelSavingsResults.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ const FuelSavingsResults = ({savings}) => {
return (
<table>
<tbody>
<tr>
<td className="fuel-savings-label">{resultLabel}</td>
<td>
<tr>
<td className="fuel-savings-label">{resultLabel}</td>
<td>
<table>
<tbody>
<tr>
Expand Down
2 changes: 1 addition & 1 deletion src/components/FuelSavingsResults.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import {shallow} from 'enzyme';
import { shallow } from 'enzyme';
import FuelSavingsResults from './FuelSavingsResults';

describe('<FuelSavingsResults />', () => {
Expand Down
14 changes: 8 additions & 6 deletions src/components/FuelSavingsTextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ const FuelSavingsTextInput = (props) => {
);
};

const { string, func, number, oneOfType } = PropTypes;

FuelSavingsTextInput.propTypes = {
name: PropTypes.string.isRequired,
onChange: PropTypes.func.isRequired,
placeholder: PropTypes.string,
value: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number
name: string.isRequired,
onChange: func.isRequired,
placeholder: string,
value: oneOfType([
string,
number
])
};

Expand Down
2 changes: 1 addition & 1 deletion src/components/FuelSavingsTextInput.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import {shallow} from 'enzyme';
import { shallow } from 'enzyme';
import FuelSavingsTextInput from './FuelSavingsTextInput';

describe('<FuelSavingsTextInput />', () => {
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
9 changes: 6 additions & 3 deletions src/components/Root.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { ConnectedRouter } from 'react-router-redux';
console.log('%cConnectedRouter', 'background:red;', ConnectedRouter);
Copy link
Owner

Choose a reason for hiding this comment

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

Looks like a console.log slipped in

import { Provider } from 'react-redux';
import routes from '../routes';
import { Router } from 'react-router';
import App from './App';

export default class Root extends Component {
render() {
const { store, history } = this.props;
return (
<Provider store={store}>
<Router history={history} routes={routes} />
<ConnectedRouter history={history}>
<App />
</ConnectedRouter>
</Provider>
);
}
Expand Down
12 changes: 2 additions & 10 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,13 @@

import React from 'react';
import { render } from 'react-dom';
import { browserHistory } from 'react-router';
import { AppContainer } from 'react-hot-loader';
import configureStore, { history } from './store/configureStore';
import Root from './components/Root';

import configureStore 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';

require('./favicon.ico'); // Tell webpack to load favicon.ico
const store = configureStore();

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


render(
<AppContainer>
<Root store={store} history={history} />
Expand Down
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
11 changes: 9 additions & 2 deletions src/store/configureStore.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
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 reactRouterMiddleware = routerMiddleware(history);
const middlewares = [
// Add other middleware on this line...

// thunk middleware can also accept an extra argument to be passed to each thunk action
// https://github.com/gaearon/redux-thunk#injecting-a-custom-argument
thunk,
reactRouterMiddleware,
];

return createStore(rootReducer, initialState, compose(
Expand All @@ -19,6 +24,7 @@ function configureStoreProd(initialState) {
}

function configureStoreDev(initialState) {
const reactRouterMiddleware = routerMiddleware(history);
const middlewares = [
// Add other middleware on this line...

Expand All @@ -28,6 +34,7 @@ function configureStoreDev(initialState) {
// thunk middleware can also accept an extra argument to be passed to each thunk action
// https://github.com/gaearon/redux-thunk#injecting-a-custom-argument
thunk,
reactRouterMiddleware,
];

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

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

export default configureStore;
export default configureStore;
Loading