Refine DataSource id to use actual key type instead of a wide string type
Summary: Current implementation uses type `string` as a key for indexing items stored in datasource. However, users can provide any key as an index which means that the type of index item can be anything, not only string. This diff introduces a more refined types for the key. It adds another requirement to provide a key property to a generic which is used to infer the index type. Reviewed By: mweststrate, aigoncharov Differential Revision: D31895751 fbshipit-source-id: 19ba907bd6f35df87e3fa442db5fc5cec6af174d
This commit is contained in:
committed by
Facebook GitHub Bot
parent
64e791e253
commit
4a4cc21d89
@@ -39,7 +39,7 @@ type DataSourceProps<T extends object, C> = {
|
||||
/**
|
||||
* The data source to render
|
||||
*/
|
||||
dataSource: DataSource<T>;
|
||||
dataSource: DataSource<T, T[keyof T]>;
|
||||
/**
|
||||
* Automatically scroll if the user is near the end?
|
||||
*/
|
||||
@@ -66,7 +66,9 @@ type DataSourceProps<T extends object, C> = {
|
||||
offset: number,
|
||||
): void;
|
||||
onUpdateAutoScroll?(autoScroll: boolean): void;
|
||||
emptyRenderer?: null | ((dataSource: DataSource<T>) => React.ReactElement);
|
||||
emptyRenderer?:
|
||||
| null
|
||||
| ((dataSource: DataSource<T, T[keyof T]>) => React.ReactElement);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user