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

Upgrade React to v16.0.0 #965

Merged
merged 6 commits into from
Nov 6, 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 packages/react-server-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"pem": "^1.8.1",
"q": "1.4.1",
"raw-loader": "^0.5.1",
"react-hot-loader": "~1.3.0",
"react-hot-loader": "^3.1.1",
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this version compatible with the older versions of React that are supported below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a comment below. Yes it is compatible, but we will lose client-side HMR because react-hot-loader now needs us to use module.hot.accept and rendering the component tree in our entrypoints rather than using the no longer supported ReactMount.
See step 2 here http://gaearon.github.io/react-hot-loader/getstarted/

"react-server-core-middleware": "^0.6.0",
"sass-loader": "^4.0.0",
"style-loader": "^0.13.1",
Expand All @@ -68,9 +68,9 @@
"mockery": "^2.0.0",
"nsp": "^2.6.2",
"output-file-sync": "^1.1.2",
"react": "~0.14.2 || ^15.1.0",
"react-dom": "~0.14.2 || ^15.1.0",
"react-hot-loader": "^1.3.1",
"react": "~0.14.9 || ^15.3.0 || ^16.0.0",
"react-dom": "~0.14.9 || ^15.3.0 || ^16.0.0",
"react-hot-loader": "^3.1.1",
"react-server": "^0.7.3",
"react-server-gulp-module-tagger": "^0.6.0",
"rimraf": "^2.5.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-server-cli/src/compileClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ function packageCodeForBrowser(entrypoints, outputDir, outputUrl, hot, minify, l
webpackConfig.module.loaders = [
{
test: /\.jsx?$/,
loader: "react-hot",
loader: "react-hot-loader/webpack",
exclude: /node_modules/,
},
...webpackConfig.module.loaders,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import PropTypes from 'prop-types';
import React from 'react';
import {logging, Link} from 'react-server';

Expand All @@ -11,17 +12,17 @@ const NetworkCard = ({id, name, location, company}) => {
};

NetworkCard.propTypes = {
company: React.PropTypes.any,
href: React.PropTypes.string,
id: React.PropTypes.string,
location: React.PropTypes.shape({
city: React.PropTypes.string,
country: React.PropTypes.string,
latitude: React.PropTypes.number,
longitude: React.PropTypes.number,
company: PropTypes.any,
href: PropTypes.string,
id: PropTypes.string,
location: PropTypes.shape({
city: PropTypes.string,
country: PropTypes.string,
latitude: PropTypes.number,
longitude: PropTypes.number,
}),
name: React.PropTypes.string,
stations: React.PropTypes.array,
name: PropTypes.string,
stations: PropTypes.array,
};

NetworkCard.displayName = 'NetworkCard';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import PropTypes from 'prop-types';
import React from 'react';
import {logging} from 'react-server';
import NetworkCard from './network-card';
Expand All @@ -13,7 +14,7 @@ const NetworkList = ({networks}) => {
};

NetworkList.propTypes = {
networks: React.PropTypes.array,
networks: PropTypes.array,
};

NetworkList.displayName = 'NetworkList';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import PropTypes from 'prop-types';
import React from 'react';
import {logging} from 'react-server';

Expand All @@ -18,15 +19,15 @@ const StationCard = ({station}) => {
};

StationCard.propTypes = {
station: React.PropTypes.shape({
empty_slots: React.PropTypes.number, // eslint-disable-line
extra: React.PropTypes.object,
free_bikes: React.PropTypes.number, // eslint-disable-line
id: React.PropTypes.string,
latitude: React.PropTypes.number,
longitude: React.PropTypes.number,
name: React.PropTypes.string,
timestamp: React.PropTypes.string,
station: PropTypes.shape({
empty_slots: PropTypes.number, // eslint-disable-line
extra: PropTypes.object,
free_bikes: PropTypes.number, // eslint-disable-line
id: PropTypes.string,
latitude: PropTypes.number,
longitude: PropTypes.number,
name: PropTypes.string,
timestamp: PropTypes.string,
}),
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import PropTypes from 'prop-types';
import React from 'react';
import {logging} from 'react-server';
import StationCard from './station-card';
Expand All @@ -11,7 +12,7 @@ const StationList = ({stations}) => {
};

StationList.propTypes = {
stations: React.PropTypes.array,
stations: PropTypes.array,
};

StationList.displayName = 'StationList';
Expand Down
3 changes: 2 additions & 1 deletion packages/react-server-examples/meteor-site/components/Map.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { default as React, PropTypes } from "react";
import PropTypes from 'prop-types';
import React from "react";
import GoogleMap from "google-map-react";

const MeteorMap = ({ defaultCenter, center , meteors }) => (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { default as React, PropTypes } from "react";
import PropTypes from 'prop-types';
import React from "react";
import { Link } from "react-server";

const headerColumns = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { Component, PropTypes } from 'react'
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { connect } from 'react-redux'

class Counter extends Component {
Expand Down
4 changes: 2 additions & 2 deletions packages/react-server-examples/styled-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"babel-preset-react-server": "^0.4.8",
"babel-runtime": "^6.6.1",
"color": "^0.11.3",
"react": "^0.14.2",
"react-dom": "0.14.2",
"react": "^0.14.9",
"react-dom": "0.14.9",
"react-server": "^0.4.8",
"react-server-cli": "^0.4.8",
"styled-components": "^1.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/react-server-integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"minimist": "^1.2.0",
"mkdirp": "^0.5.1",
"q": "1.4.1",
"react": "~0.14.2 || ^15.1.0",
"react-dom": "~0.14.2 || ^15.1.0",
"react": "~0.14.9 || ^15.3.0 || ^16.0.0",
"react-dom": "~0.14.9 || ^15.3.0 || ^16.0.0",
"react-server": "^0.7.3",
"react-server-cli": "^0.7.3",
"rimraf": "^2.5.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-server-redux/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"redux": "^3.6.0"
},
"peerDependencies": {
"react": "~0.14.2 || ^15.1.0"
"react": "~0.14.9 || ^15.3.0 || ^16.0.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are the older version numbers changing here?

Lerna will only hoist if version strings match exactly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

prop-types is only compatible with these versions. In previous versions, React will log console warnings if we use prop-types with previous versions https://www.npmjs.com/package/prop-types

},
"devDependencies": {
"ava": "^0.17.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/react-server-redux/src/RootProvider.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const PropTypes = require('prop-types');
var React = require('react');
var { Provider } = require('react-redux');

Expand Down Expand Up @@ -35,5 +36,5 @@ class RootProvider extends React.Component {
module.exports = RootProvider;

RootProvider.propTypes = {
store: React.PropTypes.object.isRequired,
store: PropTypes.object.isRequired,
}
3 changes: 2 additions & 1 deletion packages/react-server-test-pages/.reactserverrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"routesFile": "./routes.js"
"routesFile": "./routes.js",
"hot": true
}
4 changes: 2 additions & 2 deletions packages/react-server-test-pages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"dependencies": {
"lodash": "^4.16.4",
"q": "1.4.1",
"react": "~0.14.2 || ^15.1.0",
"react-dom": "~0.14.2 || ^15.1.0",
"react": "~0.14.9 || ^15.3.0 || ^16.0.0",
"react-dom": "~0.14.9 || ^15.3.0 || ^16.0.0",
"react-server": "^0.7.3",
"react-server-cli": "^0.7.3",
"react-server-data-bundle-cache": "^0.7.3",
Expand Down
3 changes: 2 additions & 1 deletion packages/react-server-test-pages/pages/root/reduxAdapter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {createStore, applyMiddleware} from "redux";
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import {RootElement} from "react-server";
import {RootProvider, ReduxAdapter} from "react-server-redux";
Expand Down Expand Up @@ -34,7 +35,7 @@ function initAction() {

class BasicComponent extends React.Component {
propTypes: {
elementData: React.PropTypes.sting.isRequired,
elementData: PropTypes.sting.isRequired,
}

render() {
Expand Down
3 changes: 2 additions & 1 deletion packages/react-server-test-pages/pages/root/rootProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {RootElement} from "react-server";
import {RootProvider} from "react-server-redux";
import {createStore} from "redux";
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import React from 'react';

function simpleReducer(state = {simpleValue: "Hello"}) {
Expand All @@ -15,7 +16,7 @@ class BasicComponent extends React.Component {
}

BasicComponent.propTypes = {
simpleValue: React.PropTypes.string,
simpleValue: PropTypes.string,
}

const mapStateToProps = function(state) {
Expand Down
7 changes: 4 additions & 3 deletions packages/react-server-website/components/Markdown.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import PropTypes from 'prop-types';
import React from 'react';

import Remarkable from 'remarkable';
Expand Down Expand Up @@ -58,9 +59,9 @@ export default class Markdown extends React.Component {
}

Markdown.propTypes = {
source : React.PropTypes.string,
reuseDom : React.PropTypes.bool,
bundleData : React.PropTypes.bool,
source : PropTypes.string,
reuseDom : PropTypes.bool,
bundleData : PropTypes.bool,
}

Markdown.defaultProps = {
Expand Down
3 changes: 2 additions & 1 deletion packages/react-server-website/components/doc-body.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import PropTypes from 'prop-types';
import React from "react";
import {Component, PropTypes} from 'react';
import { Component } from 'react';
import Markdown from './Markdown';

export default class DocBody extends Component {
Expand Down
3 changes: 2 additions & 1 deletion packages/react-server-website/components/page-title.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import PropTypes from 'prop-types';
import React from 'react';
import {Component, PropTypes} from 'react';
import { Component } from 'react';
import './page-title.less';

export default class PageTitle extends Component {
Expand Down
4 changes: 2 additions & 2 deletions packages/react-server-website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"babel-plugin-transform-runtime": "^6.15.0",
"babel-runtime": "^6.18.0",
"highlight.js": "^9.5.0",
"react": "~0.14.2 || ^15.1.0",
"react-dom": "~0.14.2 || ^15.1.0",
"react": "~0.14.9 || ^15.3.0 || ^16.0.0",
"react-dom": "~0.14.9 || ^15.3.0 || ^16.0.0",
"react-server": "^0.7.3",
"react-server-cli": "^0.7.3",
"react-server-data-bundle-cache": "^0.7.3",
Expand Down
3 changes: 2 additions & 1 deletion packages/react-server/core/ClientController.js
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,8 @@ class ClientController extends EventEmitter {
, timer = logger.timer(`renderElement.individual.${name}`)

element = React.cloneElement(element, { context: this.context });
ReactDOM.render(element, root);
var renderFunc = ReactDOM.hydrate || ReactDOM.render;
renderFunc(element, root);

_.forEach(
getRootElementAttributes(element),
Expand Down
50 changes: 28 additions & 22 deletions packages/react-server/core/components/FragmentDataCache.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

var ReactServerAgent = require("../ReactServerAgent"),
React = require("react");
React = require('react'),
PropTypes = require('prop-types');

/**
* FragmentDataCache writes out a serialized form of the ReactServerAgent request
Expand Down Expand Up @@ -36,37 +37,42 @@ var ReactServerAgent = require("../ReactServerAgent"),
* * entry.res and entry.err.response won't have any `body` entry if
* the response from the server was HTML instead of JSON.
*/
var FragmentDataCache = module.exports = React.createClass({
class FragmentDataCache extends React.Component {

propTypes: {
cacheNodeId: React.PropTypes.string,
},
static get displayName() {
return 'FragmentDataCache';
}

displayName: 'FragmentDataCache',
static get propTypes() {
return {
cacheNodeId: PropTypes.string,
};
}

getDefaultProps: function () {
static get defaultProps() {
return {
cacheNodeId: "react-server-fragment-data-cache",
}
},
};
}

/**
* Return a promise that resolves with the FragmentDataCache component
* when all pending data requests have resolved.
*/
static createWhenReady(fragmentDataCacheProps = {}) {
return ReactServerAgent.cache().whenAllPendingResolve().then(() => {
return <FragmentDataCache {...fragmentDataCacheProps} />;
});
}

render: function () {
render() {
return (
<div
id={this.props.cacheNodeId}
data-react-server-data-cache={JSON.stringify(ReactServerAgent.cache().dehydrate({ responseBodyOnly: true }))}>
</div>
);
},

});
}
};

/**
* Return a promise that resolves with the FragmentDataCache component
* when all pending data requests have resolved.
*/
FragmentDataCache.createWhenReady = function (fragmentDataCacheProps = {}) {
return ReactServerAgent.cache().whenAllPendingResolve().then(() => {
return <FragmentDataCache {...fragmentDataCacheProps} />;
});
}
module.exports = FragmentDataCache;
Loading