Skip to content

Commit

Permalink
Fix type in useCSVDownloader (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bunlong committed Jan 26, 2022
1 parent 8dc552a commit 8cff59e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/useCSVDownloader.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { ReactNode, CSSProperties, useMemo } from 'react';
import PapaParse, { UnparseConfig } from 'papaparse';

const Type = {
Expand All @@ -7,11 +7,11 @@ const Type = {
} as const;

export interface Props {
children: React.ReactNode;
children: ReactNode;
data: any;
filename: string;
type?: 'link' | 'button';
style?: any;
style?: CSSProperties;
className?: string;
bom?: boolean;
config?: UnparseConfig;
Expand Down Expand Up @@ -47,6 +47,8 @@ function useCSVDownloaderComponent() {
type: 'text/csv;charset=utf-8;',
});

// FIX: Navigator interface no longer extends MSFileSaver
// https://github.com/microsoft/TypeScript/issues/45612
const navObj: any = window.navigator;
if (navObj.msSaveBlob) {
csvURL = navObj.msSaveBlob(csvData, `${filename}.csv`);
Expand Down Expand Up @@ -80,7 +82,7 @@ function useCSVDownloaderComponent() {
);
};

const CSVDownloader = React.useMemo(() => CSVDownloaderComponent, []) as any;
const CSVDownloader = useMemo(() => CSVDownloaderComponent, []);

return CSVDownloader;
}
Expand Down

0 comments on commit 8cff59e

Please sign in to comment.