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

[EuiInMemoryTable] Avoid blocking update for getDerivedStateFromProps #3579

Merged
merged 3 commits into from
Jun 10, 2020
Merged
Changes from 1 commit
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
14 changes: 10 additions & 4 deletions src/components/basic_table/in_memory_table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,11 @@ export class EuiInMemoryTable<T> extends Component<
nextProps: EuiInMemoryTableProps<T>,
prevState: State<T>
) {
let updatedPrevState = prevState;
if (nextProps.items !== prevState.prevProps.items) {
// We have new items because an external search has completed, so reset pagination state.
return {
updatedPrevState = {
...updatedPrevState,
prevProps: {
...prevState.prevProps,
thompsongl marked this conversation as resolved.
Show resolved Hide resolved
items: nextProps.items,
Expand All @@ -264,7 +266,8 @@ export class EuiInMemoryTable<T> extends Component<
sortName !== prevState.prevProps.sortName ||
sortDirection !== prevState.prevProps.sortDirection
) {
return {
updatedPrevState = {
...updatedPrevState,
sortName,
sortDirection,
};
Expand All @@ -278,15 +281,18 @@ export class EuiInMemoryTable<T> extends Component<
: '';

if (nextQuery !== prevQuery) {
return {
updatedPrevState = {
...updatedPrevState,
prevProps: {
...prevState.prevProps,
thompsongl marked this conversation as resolved.
Show resolved Hide resolved
search: nextProps.search,
},
query: getQueryFromSearch(nextProps.search, false),
};
}

if (updatedPrevState !== prevState) {
thompsongl marked this conversation as resolved.
Show resolved Hide resolved
return updatedPrevState;
}
return null;
}

Expand Down