Fix initialisation error
Summary: There was an initialisation error possible if the crash reporter tried to start with an initial selection (after coming from a deeplink or the notification pane), which would cause an unending update loop. Reviewed By: passy Differential Revision: D29331127 fbshipit-source-id: 14e75e483c232039e6a80aa131fa5ce7c105b670
This commit is contained in:
committed by
Facebook GitHub Bot
parent
db787d5d42
commit
2127dea447
@@ -357,12 +357,16 @@ export function DataTable<T extends object>(
|
||||
[dataSource, tableState.sorting],
|
||||
);
|
||||
|
||||
const isMounted = useRef(false);
|
||||
useEffect(
|
||||
function triggerSelection() {
|
||||
onSelect?.(
|
||||
getSelectedItem(dataSource, tableState.selection),
|
||||
getSelectedItems(dataSource, tableState.selection),
|
||||
);
|
||||
if (isMounted.current) {
|
||||
onSelect?.(
|
||||
getSelectedItem(dataSource, tableState.selection),
|
||||
getSelectedItems(dataSource, tableState.selection),
|
||||
);
|
||||
}
|
||||
isMounted.current = true;
|
||||
},
|
||||
[onSelect, dataSource, tableState.selection],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user