Introduce pluginKey
Summary: Exposed the `pluginKey` to sandy plugins (which we will use later for storing table preferences per plugin). And a little moving code around because circular deps problem roared its ugly head again. Reviewed By: nikoant Differential Revision: D27009721 fbshipit-source-id: 7ad29e72ff8028c9daae270c4749b657bd8ff049
This commit is contained in:
committed by
Facebook GitHub Bot
parent
be25df6490
commit
2ca52f81d2
@@ -44,8 +44,8 @@ import {tableContextMenuFactory} from './TableContextMenu';
|
||||
import {Typography} from 'antd';
|
||||
import {CoffeeOutlined, SearchOutlined} from '@ant-design/icons';
|
||||
import {useAssertStableRef} from '../../utils/useAssertStableRef';
|
||||
import {TrackingScopeContext} from 'flipper-plugin/src/ui/Tracked';
|
||||
import {Formatter} from '../DataFormatter';
|
||||
import {usePluginInstance} from '../../plugin/PluginContext';
|
||||
|
||||
interface DataTableProps<T = any> {
|
||||
columns: DataTableColumn<T>[];
|
||||
@@ -103,7 +103,7 @@ export function DataTable<T extends object>(
|
||||
|
||||
// lint disabled for conditional inclusion of a hook (_testHeight is asserted to be stable)
|
||||
// eslint-disable-next-line
|
||||
const scope = props._testHeight ? "" : useContext(TrackingScopeContext); // TODO + plugin id
|
||||
const scope = props._testHeight ? "" : usePluginInstance().pluginKey;
|
||||
const virtualizerRef = useRef<DataSourceVirtualizer | undefined>();
|
||||
const [state, dispatch] = useReducer(
|
||||
dataTableManagerReducer as DataTableReducer<T>,
|
||||
|
||||
@@ -104,7 +104,6 @@ export type DataTableReducer<T> = Reducer<
|
||||
>;
|
||||
export type DataTableDispatch<T = any> = React.Dispatch<DataManagerActions<T>>;
|
||||
|
||||
// TODO: make argu inference correct
|
||||
export const dataTableManagerReducer = produce(function <T>(
|
||||
draft: DataManagerState<T>,
|
||||
action: DataManagerActions<T>,
|
||||
@@ -208,7 +207,7 @@ export const dataTableManagerReducer = produce(function <T>(
|
||||
throw new Error('Unknown action ' + (action as any).type);
|
||||
}
|
||||
}
|
||||
}) as any; // TODO: remove
|
||||
}) as any;
|
||||
|
||||
/**
|
||||
* Public only imperative convienience API for DataTable
|
||||
|
||||
Reference in New Issue
Block a user