@talend/react-bootstrap
Version:
Bootstrap 3 components built with React
26 lines (25 loc) • 1.1 kB
JavaScript
import { cloneElement } from 'react';
import ReactDOM from 'react-dom';
export 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
*/
export function render(element, mountPoint) {
const mount = mountPoint || document.createElement('div');
const instance = ReactDOM.createRoot(element, mount);
if (instance && !instance.renderWithProps) {
instance.renderWithProps = newProps => render(/*#__PURE__*/cloneElement(element, newProps), mount);
}
return instance;
}
export function getOne(collection) {
expect(collection.length).to.equal(1);
return collection[0];
}
//# sourceMappingURL=helpers.js.map