Skip to content

Commit

Permalink
[React@18 failing test] Navigate to dataset details should navigate t…
Browse files Browse the repository at this point in the history
…o details page from a main page. (#196384)

## Summary

Hi team, we're working on upgrading Kibana to React@18 in legacy mode
elastic/kibana-team#1016 (comment)
and addressing remaining functional tests when running with React@18 in
Legacy Mode.

One failure we've found is happening on the dataset quality page:
navigate to dataset details should navigate to details page from a main
page.
[Failure](https://buildkite.com/elastic/kibana-pull-request/builds/236562#019222ec-e95e-44aa-a754-fd9f736accce).

I tracked it down to infinite re-render of `DegradedDocs` component.
Looks like there is an infinite useEffect loop that is also happening
with react@17, but the results of it are not so severe so the tests are
still passing and the page is still functioning with react@17, wheres
with react@18 it becomes completely unresponsive.

This effect causes the inifite loop because `breakdown` is new object
with each render:


https://github.com/elastic/kibana/blob/0d19367fdfad5526b5220dfdf18b4991fe6b3abd/x-pack/plugins/observability_solution/dataset_quality/public/components/dataset_quality_details/overview/document_trends/degraded_docs/index.tsx#L85-L91

To reproduce the loop, I used the setup from the following functional
tests suite:
x-pack/test/functional/apps/dataset_quality/dataset_quality_details.ts
  • Loading branch information
Dosant authored Oct 17, 2024
1 parent 77102c1 commit 6f4346e
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,16 +194,20 @@ export const useDegradedDocsChart = () => {

const extraActions: Action[] = [getOpenInLensAction, getOpenInLogsExplorerAction];

return {
attributes,
dataView,
breakdown: {
const breakdown = useMemo(() => {
return {
dataViewField: breakdownDataViewField,
fieldSupportsBreakdown: breakdownDataViewField
? fieldSupportsBreakdown(breakdownDataViewField)
: true,
onChange: handleBreakdownFieldChange,
},
};
}, [breakdownDataViewField, handleBreakdownFieldChange]);

return {
attributes,
dataView,
breakdown,
extraActions,
isChartLoading,
onChartLoading: handleChartLoading,
Expand Down

0 comments on commit 6f4346e

Please sign in to comment.