Skip to content

Commit 899e618

Browse files
tmobairdjustin808
authored andcommitted
Updating JS node modules that are directly related to react (react, redux, react-router, etc.) (shakacode#414)
1 parent 8c5b494 commit 899e618

File tree

18 files changed

+235
-118
lines changed

18 files changed

+235
-118
lines changed

client/app/bundles/comments/components/CommentBox/CommentBox.jsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, { PropTypes } from 'react';
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
23
import Immutable from 'immutable';
34
import ActionCable from 'actioncable';
45
import _ from 'lodash';
@@ -15,13 +16,13 @@ class CommentBox extends BaseComponent {
1516
static propTypes = {
1617
pollInterval: PropTypes.number.isRequired,
1718
actions: PropTypes.shape({
18-
fetchComments: React.PropTypes.function,
19+
fetchComments: PropTypes.function,
1920
}),
2021
data: PropTypes.shape({
21-
isFetching: React.PropTypes.boolean,
22-
isSaving: React.PropTypes.boolean,
23-
submitCommentError: React.PropTypes.string,
24-
$$comments: React.PropTypes.arrayOf(CommentPropTypes),
22+
isFetching: PropTypes.boolean,
23+
isSaving: PropTypes.boolean,
24+
submitCommentError: PropTypes.string,
25+
$$comments: PropTypes.arrayOf(CommentPropTypes),
2526
}).isRequired,
2627
intl: intlShape.isRequired,
2728
};

client/app/bundles/comments/components/CommentBox/CommentForm/CommentForm.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// NOTE: https://github.com/react-bootstrap/react-bootstrap/issues/1850 seesm to require string
22
// refs and not the callback kind.
33
/* eslint-disable react/no-find-dom-node, react/no-string-refs */
4-
import React, { PropTypes } from 'react';
4+
import React from 'react';
5+
import PropTypes from 'prop-types';
56
import ReactDOM from 'react-dom';
67
import Col from 'react-bootstrap/lib/Col';
78
import FormControl from 'react-bootstrap/lib/FormControl';

client/app/bundles/comments/components/CommentBox/CommentList/Comment/Comment.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import BaseComponent from 'libs/components/BaseComponent';
2-
import React, { PropTypes } from 'react';
2+
import React from 'react';
3+
import PropTypes from 'prop-types';
34

45
import marked from 'marked';
56
import css from './Comment.scss';

client/app/bundles/comments/components/CommentBox/CommentList/CommentList.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import Alert from 'react-bootstrap/lib/Alert';
22
import BaseComponent from 'libs/components/BaseComponent';
33
import Immutable from 'immutable';
4-
import React, { PropTypes } from 'react';
4+
import React from 'react';
5+
import PropTypes from 'prop-types';
56
import ReactCSSTransitionGroup from 'react-addons-css-transition-group';
67
import _ from 'lodash';
78

client/app/bundles/comments/components/CommentScreen/CommentScreen.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, { PropTypes } from 'react';
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
23

34
import BaseComponent from 'libs/components/BaseComponent';
45

client/app/bundles/comments/components/NavigationBar/CommentsCount.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, { PropTypes } from 'react';
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
23

34
const href = 'https://github.com/shakacode/react_on_rails/blob/master/README.md#multiple-react-' +
45
'components-on-a-page-with-one-store';

client/app/bundles/comments/components/NavigationBar/NavigationBar.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
import classNames from 'classnames';
55
import _ from 'lodash';
6-
import React, { PropTypes } from 'react';
6+
import React from 'react';
7+
import PropTypes from 'prop-types';
78

89
import CommentsCount from './CommentsCount';
910
import * as paths from '../../constants/paths';
Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
11
import React from 'react';
2+
import { Redirect } from 'react-router-dom';
23

34
import BaseComponent from 'libs/components/BaseComponent';
45

56
export default class TestReactRouterRedirect extends BaseComponent {
6-
static checkAuth(nextState, replace) {
7+
8+
static checkAuth() {
79
// Hard code this to demonstrate the effect
810
const notAuthorized = true;
9-
if (notAuthorized) {
10-
replace({ pathname: '/', state: { redirectFrom: nextState.location.pathname } });
11-
}
11+
return notAuthorized;
1212
}
1313

1414
render() {
15-
return (
16-
<div>Nope.</div>
17-
);
18-
}
15+
if (TestReactRouterRedirect.checkAuth()) {
16+
return (
17+
<Redirect
18+
push
19+
to={{
20+
pathname: '/',
21+
state: { redirectFrom: this.props.location.pathname },
22+
}}
23+
/>
24+
);
25+
}
1926

27+
return <div>Nope.</div>;
28+
}
2029
}

client/app/bundles/comments/containers/NavigationBarContainer.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, { PropTypes } from 'react';
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
23
import { connect } from 'react-redux';
34

45
import BaseComponent from 'libs/components/BaseComponent';

client/app/bundles/comments/containers/NonRouterCommentsContainer.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, { PropTypes } from 'react';
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
23
import { connect } from 'react-redux';
34
import { bindActionCreators } from 'redux';
45
import BaseComponent from 'libs/components/BaseComponent';

client/app/bundles/comments/containers/RouterCommentsContainer.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, { PropTypes } from 'react';
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
23
import { connect } from 'react-redux';
34
import { bindActionCreators } from 'redux';
45
import { IntlProvider } from 'react-intl';

client/app/bundles/comments/layout/Layout.jsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import React, { PropTypes } from 'react';
2-
import { IndexLink, Link } from 'react-router';
3-
import BaseComponent from 'libs/components/BaseComponent';
1+
import React, { Component } from 'react';
2+
import PropTypes from 'prop-types';
3+
import { NavLink as Link } from 'react-router-dom';
44

55
import './Layout.scss';
66

7-
export default class Layout extends BaseComponent {
7+
/* eslint-disable react/prefer-stateless-function */
8+
export default class Layout extends Component {
89

910
static propTypes = {
1011
children: PropTypes.object.isRequired,
@@ -17,9 +18,9 @@ export default class Layout extends BaseComponent {
1718
<header>
1819
<ul>
1920
<li>
20-
<IndexLink to="/" activeClassName="active">
21+
<Link to="/" activeClassName="active">
2122
Comments (Root URL)
22-
</IndexLink>
23+
</Link>
2324
</li>
2425
<li>
2526
<Link to="/react-router" activeClassName="active">
Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
import React from 'react';
2-
import { Route, IndexRoute } from 'react-router';
2+
import { Route, Switch } from 'react-router-dom';
33
import Layout from '../layout/Layout';
44
import TestReactRouter from '../components/TestReactRouter/TestReactRouter';
55
import TestReactRouterRedirect from '../components/TestReactRouterRedirect/TestReactRouterRedirect';
66
import RouterCommentsContainer from '../containers/RouterCommentsContainer';
77

88
export default (
9-
<Route path="/" component={Layout}>
10-
<IndexRoute
11-
component={RouterCommentsContainer}
12-
/>
13-
<Route
14-
path="react-router"
15-
component={TestReactRouter}
16-
/>
17-
<Route
18-
path="react-router/redirect"
19-
component={TestReactRouterRedirect}
20-
onEnter={TestReactRouterRedirect.checkAuth}
21-
/>
22-
</Route>
9+
<Layout>
10+
<Switch>
11+
<Route
12+
path="/"
13+
component={RouterCommentsContainer}
14+
exact
15+
/>
16+
<Route
17+
path="/react-router"
18+
component={TestReactRouter}
19+
exact
20+
/>
21+
<Route
22+
path="/react-router/redirect"
23+
component={TestReactRouterRedirect}
24+
/>
25+
</Switch>
26+
</Layout>
2327
);

client/app/bundles/comments/startup/ClientRouterApp.jsx

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,17 @@
22
import React from 'react';
33
import { Provider } from 'react-redux';
44
import ReactOnRails from 'react-on-rails';
5-
import { syncHistoryWithStore } from 'react-router-redux';
6-
import { Router, browserHistory } from 'react-router';
7-
5+
import { BrowserRouter } from 'react-router-dom';
86
import routes from '../routes/routes';
97

108
export default (_props, _railsContext) => {
119
const store = ReactOnRails.getStore('routerCommentsStore');
1210

13-
// Create an enhanced history that syncs navigation events with the store
14-
const history = syncHistoryWithStore(
15-
browserHistory,
16-
store,
17-
);
18-
1911
return (
2012
<Provider store={store}>
21-
<Router history={history}>
13+
<BrowserRouter>
2214
{routes}
23-
</Router>
15+
</BrowserRouter>
2416
</Provider>
2517
);
2618
};
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
// Compare to ../ClientRouterApp.jsx
22
import React from 'react';
33
import { Provider } from 'react-redux';
4-
import { match, RouterContext } from 'react-router';
4+
import { StaticRouter } from 'react-router';
55
import ReactOnRails from 'react-on-rails';
6-
76
import routes from '../routes/routes';
87

98
export default (_props, railsContext) => {
109
const store = ReactOnRails.getStore('routerCommentsStore');
1110

1211
let error;
1312
let redirectLocation;
14-
let routeProps;
1513
const { location } = railsContext;
1614

17-
// See https://github.com/reactjs/react-router/blob/master/docs/guides/ServerRendering.md
18-
match({ routes, location }, (_error, _redirectLocation, _routeProps) => {
19-
error = _error;
20-
redirectLocation = _redirectLocation;
21-
routeProps = _routeProps;
22-
});
23-
2415
// This tell react_on_rails to skip server rendering any HTML. Note, client rendering
2516
// will handle the redirect. What's key is that we don't try to render.
2617
// Critical to return the Object properties to match this { error, redirectLocation }
2718
if (error || redirectLocation) {
2819
return { error, redirectLocation };
2920
}
3021

22+
// Allows components to add properties to the object to store
23+
// information about the render.
24+
const context = {};
25+
3126
// Important that you don't do this if you are redirecting or have an error.
3227
return (
3328
<Provider store={store}>
34-
<RouterContext {...routeProps} />
29+
<StaticRouter
30+
location={location}
31+
context={context}
32+
>
33+
{routes}
34+
</StaticRouter>
3535
</Provider>
3636
);
3737
};

client/package.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,16 @@
7777
"node-sass": "^4.5.2",
7878
"node-uuid": "^1.4.8",
7979
"postcss-loader": "^1.3.3",
80-
"react": "^15.4.1",
81-
"react-addons-css-transition-group": "^15.4.1",
82-
"react-bootstrap": "^0.30.8",
83-
"react-dom": "^15.4.1",
84-
"react-intl": "^2.2.2",
80+
"prop-types": "^15.5.10",
81+
"react": "^15.6.1",
82+
"react-addons-css-transition-group": "^15.6.0",
83+
"react-bootstrap": "^0.31.2",
84+
"react-dom": "^15.6.1",
85+
"react-intl": "^2.3.0",
8586
"react-on-rails": "^8.0.6-rc.1",
86-
"react-redux": "^4.4.6",
87-
"react-router": "^3.0.0",
87+
"react-redux": "^5.0.5",
88+
"react-router": "^4.1.2",
89+
"react-router-dom": "^4.1.2",
8890
"react-router-redux": "^4.0.7",
8991
"redux": "^3.6.0",
9092
"redux-thunk": "^2.2.0",

0 commit comments

Comments
 (0)