Fix some bugs in the UI Framework caused by the React 16 upgrade. (#15544) (#15559)

This commit is contained in:
CJ Cenizal 2017-12-12 09:49:34 -08:00 committed by GitHub
parent 15fadeda2d
commit de285c712a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 11 deletions

View file

@ -98,8 +98,8 @@
"babel-plugin-transform-define": "1.3.0",
"babel-plugin-transform-object-rest-spread": "6.23.0",
"babel-polyfill": "6.20.0",
"babel-preset-env": "1.4.0",
"babel-preset-react": "6.22.0",
"babel-preset-env": "1.6.1",
"babel-preset-react": "6.24.1",
"babel-register": "6.18.0",
"bluebird": "2.9.34",
"body-parser": "1.12.0",
@ -177,7 +177,7 @@
"react-input-range": "1.2.1",
"react-markdown": "3.1.0",
"react-redux": "5.0.5",
"react-router": "2.0.0",
"react-router": "3.2.0",
"react-router-dom": "4.2.2",
"react-router-redux": "4.0.4",
"react-select": "1.0.0-rc.5",

View file

@ -2,16 +2,27 @@ import React from 'react';
import {
render,
configure
} from 'enzyme';
import EnzymeAdapter from 'enzyme-adapter-react-16';
import html from 'html';
configure({ adapter: new EnzymeAdapter() });
export function renderToHtml(componentReference, props = {}) {
// Create the React element, render it and get its HTML, then format it prettily.
const element = React.createElement(componentReference, props);
const htmlString = render(element).html();
return html.prettyPrint(htmlString, {
indent_size: 2,
unformatted: [], // Expand all tags, including spans
});
// If there's a failure, just return an empty string. The actual component itself should
// trip an error boundary in the UI when it fails.
try {
// Create the React element, render it and get its HTML, then format it prettily.
const element = React.createElement(componentReference, props);
const htmlString = render(element).html();
return html.prettyPrint(htmlString, {
indent_size: 2,
unformatted: [], // Expand all tags, including spans
});
} catch(e) {
return '';
}
}

View file

@ -1,4 +1,5 @@
import React, { PropTypes } from 'react';
import React from 'react';
import PropTypes from 'prop-types';
import {
KuiExpression,
KuiExpressionButton,