Skip to content

Updating JS node modules that are directly related to react (react, r… #414

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

Merged
merged 1 commit into from
Aug 11, 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
13 changes: 7 additions & 6 deletions client/app/bundles/comments/components/CommentBox/CommentBox.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { PropTypes } from 'react';
import React from 'react';
import PropTypes from 'prop-types';
import Immutable from 'immutable';
import ActionCable from 'actioncable';
import _ from 'lodash';
Expand All @@ -15,13 +16,13 @@ class CommentBox extends BaseComponent {
static propTypes = {
pollInterval: PropTypes.number.isRequired,
actions: PropTypes.shape({
fetchComments: React.PropTypes.function,
fetchComments: PropTypes.function,
}),
data: PropTypes.shape({
isFetching: React.PropTypes.boolean,
isSaving: React.PropTypes.boolean,
submitCommentError: React.PropTypes.string,
$$comments: React.PropTypes.arrayOf(CommentPropTypes),
isFetching: PropTypes.boolean,
isSaving: PropTypes.boolean,
submitCommentError: PropTypes.string,
$$comments: PropTypes.arrayOf(CommentPropTypes),
}).isRequired,
intl: intlShape.isRequired,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// NOTE: https://github.com/react-bootstrap/react-bootstrap/issues/1850 seesm to require string
// refs and not the callback kind.
/* eslint-disable react/no-find-dom-node, react/no-string-refs */
import React, { PropTypes } from 'react';
import React from 'react';
import PropTypes from 'prop-types';
import ReactDOM from 'react-dom';
import Col from 'react-bootstrap/lib/Col';
import FormControl from 'react-bootstrap/lib/FormControl';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import BaseComponent from 'libs/components/BaseComponent';
import React, { PropTypes } from 'react';
import React from 'react';
import PropTypes from 'prop-types';

import marked from 'marked';
import css from './Comment.scss';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import Alert from 'react-bootstrap/lib/Alert';
import BaseComponent from 'libs/components/BaseComponent';
import Immutable from 'immutable';
import React, { PropTypes } from 'react';
import React from 'react';
import PropTypes from 'prop-types';
import ReactCSSTransitionGroup from 'react-addons-css-transition-group';
import _ from 'lodash';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { PropTypes } from 'react';
import React from 'react';
import PropTypes from 'prop-types';

import BaseComponent from 'libs/components/BaseComponent';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { PropTypes } from 'react';
import React from 'react';
import PropTypes from 'prop-types';

const href = 'https://github.com/shakacode/react_on_rails/blob/master/README.md#multiple-react-' +
'components-on-a-page-with-one-store';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

import classNames from 'classnames';
import _ from 'lodash';
import React, { PropTypes } from 'react';
import React from 'react';
import PropTypes from 'prop-types';

import CommentsCount from './CommentsCount';
import * as paths from '../../constants/paths';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
import React from 'react';
import { Redirect } from 'react-router-dom';

import BaseComponent from 'libs/components/BaseComponent';

export default class TestReactRouterRedirect extends BaseComponent {
static checkAuth(nextState, replace) {

static checkAuth() {
// Hard code this to demonstrate the effect
const notAuthorized = true;
if (notAuthorized) {
replace({ pathname: '/', state: { redirectFrom: nextState.location.pathname } });
}
return notAuthorized;
}

render() {
return (
<div>Nope.</div>
);
}
if (TestReactRouterRedirect.checkAuth()) {
return (
<Redirect
push
to={{
pathname: '/',
state: { redirectFrom: this.props.location.pathname },
}}
/>
);
}

return <div>Nope.</div>;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { PropTypes } from 'react';
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';

import BaseComponent from 'libs/components/BaseComponent';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { PropTypes } from 'react';
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import BaseComponent from 'libs/components/BaseComponent';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { PropTypes } from 'react';
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { IntlProvider } from 'react-intl';
Expand Down
13 changes: 7 additions & 6 deletions client/app/bundles/comments/layout/Layout.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React, { PropTypes } from 'react';
import { IndexLink, Link } from 'react-router';
import BaseComponent from 'libs/components/BaseComponent';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { NavLink as Link } from 'react-router-dom';

import './Layout.scss';

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

static propTypes = {
children: PropTypes.object.isRequired,
Expand All @@ -17,9 +18,9 @@ export default class Layout extends BaseComponent {
<header>
<ul>
<li>
<IndexLink to="/" activeClassName="active">
<Link to="/" activeClassName="active">
Comments (Root URL)
</IndexLink>
</Link>
</li>
<li>
<Link to="/react-router" activeClassName="active">
Expand Down
34 changes: 19 additions & 15 deletions client/app/bundles/comments/routes/routes.jsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
import React from 'react';
import { Route, IndexRoute } from 'react-router';
import { Route, Switch } from 'react-router-dom';
import Layout from '../layout/Layout';
import TestReactRouter from '../components/TestReactRouter/TestReactRouter';
import TestReactRouterRedirect from '../components/TestReactRouterRedirect/TestReactRouterRedirect';
import RouterCommentsContainer from '../containers/RouterCommentsContainer';

export default (
<Route path="/" component={Layout}>
<IndexRoute
component={RouterCommentsContainer}
/>
<Route
path="react-router"
component={TestReactRouter}
/>
<Route
path="react-router/redirect"
component={TestReactRouterRedirect}
onEnter={TestReactRouterRedirect.checkAuth}
/>
</Route>
<Layout>
<Switch>
<Route
path="/"
component={RouterCommentsContainer}
exact
/>
<Route
path="/react-router"
component={TestReactRouter}
exact
/>
<Route
path="/react-router/redirect"
component={TestReactRouterRedirect}
/>
</Switch>
</Layout>
);
14 changes: 3 additions & 11 deletions client/app/bundles/comments/startup/ClientRouterApp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,17 @@
import React from 'react';
import { Provider } from 'react-redux';
import ReactOnRails from 'react-on-rails';
import { syncHistoryWithStore } from 'react-router-redux';
import { Router, browserHistory } from 'react-router';

import { BrowserRouter } from 'react-router-dom';
import routes from '../routes/routes';

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

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

return (
<Provider store={store}>
<Router history={history}>
<BrowserRouter>
{routes}
</Router>
</BrowserRouter>
</Provider>
);
};
22 changes: 11 additions & 11 deletions client/app/bundles/comments/startup/ServerRouterApp.jsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
// Compare to ../ClientRouterApp.jsx
import React from 'react';
import { Provider } from 'react-redux';
import { match, RouterContext } from 'react-router';
import { StaticRouter } from 'react-router';
import ReactOnRails from 'react-on-rails';

import routes from '../routes/routes';

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

let error;
let redirectLocation;
let routeProps;
const { location } = railsContext;

// See https://github.com/reactjs/react-router/blob/master/docs/guides/ServerRendering.md
match({ routes, location }, (_error, _redirectLocation, _routeProps) => {
error = _error;
redirectLocation = _redirectLocation;
routeProps = _routeProps;
});

// This tell react_on_rails to skip server rendering any HTML. Note, client rendering
// will handle the redirect. What's key is that we don't try to render.
// Critical to return the Object properties to match this { error, redirectLocation }
if (error || redirectLocation) {
return { error, redirectLocation };
}

// Allows components to add properties to the object to store
// information about the render.
const context = {};

// Important that you don't do this if you are redirecting or have an error.
return (
<Provider store={store}>
<RouterContext {...routeProps} />
<StaticRouter
location={location}
context={context}
>
{routes}
</StaticRouter>
</Provider>
);
};
16 changes: 9 additions & 7 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,16 @@
"node-sass": "^4.5.2",
"node-uuid": "^1.4.8",
"postcss-loader": "^1.3.3",
"react": "^15.4.1",
"react-addons-css-transition-group": "^15.4.1",
"react-bootstrap": "^0.30.8",
"react-dom": "^15.4.1",
"react-intl": "^2.2.2",
"prop-types": "^15.5.10",
"react": "^15.6.1",
"react-addons-css-transition-group": "^15.6.0",
"react-bootstrap": "^0.31.2",
"react-dom": "^15.6.1",
"react-intl": "^2.3.0",
"react-on-rails": "^8.0.6-rc.1",
"react-redux": "^4.4.6",
"react-router": "^3.0.0",
"react-redux": "^5.0.5",
"react-router": "^4.1.2",
"react-router-dom": "^4.1.2",
"react-router-redux": "^4.0.7",
"redux": "^3.6.0",
"redux-thunk": "^2.2.0",
Expand Down
Loading