UNPKG

@talend/react-bootstrap

Version:

Bootstrap 3 components built with React

35 lines (33 loc) 1.37 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getOne = getOne; exports.render = render; exports.shouldWarn = shouldWarn; var _react = require("react"); var _reactDom = _interopRequireDefault(require("react-dom")); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } function shouldWarn(about) { console.error.expected.push(about); // eslint-disable-line no-console } /** * Helper for rendering and updating props for plain class Components * since `setProps` is deprecated. * @param {ReactElement} element Root element to render * @param {HTMLElement?} mountPoint Optional mount node, when empty it uses an unattached div like `renderIntoDocument()` * @return {ComponentInstance} The instance, with a new method `renderWithProps` which will return a new instance with updated props */ function render(element, mountPoint) { const mount = mountPoint || document.createElement('div'); const instance = _reactDom.default.createRoot(element, mount); if (instance && !instance.renderWithProps) { instance.renderWithProps = newProps => render(/*#__PURE__*/(0, _react.cloneElement)(element, newProps), mount); } return instance; } function getOne(collection) { expect(collection.length).to.equal(1); return collection[0]; } //# sourceMappingURL=helpers.js.map