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

[Maps] Fix issue preventing TMS from rendering correctly #71946

Merged
merged 4 commits into from
Jul 16, 2020
Merged
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import React from 'react';
import React, { useEffect } from 'react';
import PropTypes from 'prop-types';
import { EuiFieldText, EuiFormRow, EuiPanel } from '@elastic/eui';

Expand All @@ -13,10 +13,12 @@ import { i18n } from '@kbn/i18n';

export function CreateSourceEditor({ onSourceConfigChange }) {
const tilemap = getKibanaTileMap();

if (tilemap.url) {
onSourceConfigChange();
}
useEffect(() => {
if (tilemap.url) {
onSourceConfigChange();
}
// eslint-disable-next-line react-hooks/exhaustive-deps
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Passing an empty array to useEffect has the effect of only executing once on mount like componentDidMount for functional components. It's the generally accepted stand-in for componentDidMount but still triggers the linter

}, []);

return (
<EuiPanel>
Expand All @@ -33,7 +35,7 @@ export function CreateSourceEditor({ onSourceConfigChange }) {
})
}
>
<EuiFieldText readOnly value={tilemap.url} />
<EuiFieldText readOnly value={tilemap.url ? tilemap.url : ''} />
</EuiFormRow>
</EuiPanel>
);
Expand Down