mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[Management] Prevent react warnings in index pattern creation (#16520)
* Prevent react warnings * Use common function, PR feedback
This commit is contained in:
parent
c25548566f
commit
b69947781f
2 changed files with 16 additions and 1 deletions
|
@ -7,6 +7,7 @@ const { renderStepIndexPattern, destroyStepIndexPattern } = require('../index');
|
|||
|
||||
describe('StepIndexPatternRender', () => {
|
||||
beforeEach(() => {
|
||||
jest.spyOn(document, 'getElementById').mockImplementation(() => ({}));
|
||||
render.mockClear();
|
||||
unmountComponentAtNode.mockClear();
|
||||
});
|
||||
|
|
|
@ -2,6 +2,10 @@ import React from 'react';
|
|||
import { render, unmountComponentAtNode } from 'react-dom';
|
||||
import { StepIndexPattern } from './step_index_pattern';
|
||||
|
||||
function getNode(domElementId) {
|
||||
return document.getElementById(domElementId);
|
||||
}
|
||||
|
||||
export function renderStepIndexPattern(
|
||||
domElementId,
|
||||
allIndices,
|
||||
|
@ -10,6 +14,11 @@ export function renderStepIndexPattern(
|
|||
esService,
|
||||
goToNextStep,
|
||||
) {
|
||||
const node = getNode(domElementId);
|
||||
if (!node) {
|
||||
return;
|
||||
}
|
||||
|
||||
render(
|
||||
<StepIndexPattern
|
||||
allIndices={allIndices}
|
||||
|
@ -23,5 +32,10 @@ export function renderStepIndexPattern(
|
|||
}
|
||||
|
||||
export function destroyStepIndexPattern(domElementId) {
|
||||
unmountComponentAtNode(document.getElementById(domElementId));
|
||||
const node = getNode(domElementId);
|
||||
if (!node) {
|
||||
return;
|
||||
}
|
||||
|
||||
unmountComponentAtNode(node);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue