Skip to content

Commit

Permalink
[@portaljs/components][sm] - fix bug of multiple flatuitable with dif…
Browse files Browse the repository at this point in the history
…ferent urls
  • Loading branch information
luccasmmg committed Aug 14, 2023
1 parent 88ccee6 commit 8e89613
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/lovely-ghosts-sin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@portaljs/components': patch
---

fix bug when there were multiple flatuitable components at the same time
Binary file removed packages/components/portaljs-components-0.1.12.tgz
Binary file not shown.
15 changes: 12 additions & 3 deletions packages/components/src/components/FlatUiTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,25 @@ export interface FlatUiTableProps {
data?: { [key: string]: number | string }[];
rawCsv?: string;
corsProxy?: string;
randomId?: number;
}
export const FlatUiTable: React.FC<FlatUiTableProps> = ({
url,
data,
rawCsv,
corsProxy,
}) => {
const randomId = Math.random();
return (
// Provide the client to your App
<QueryClientProvider client={queryClient}>
<TableInner corsProxy={corsProxy} url={url} data={data} rawCsv={rawCsv} />
<TableInner
corsProxy={corsProxy}
url={url}
data={data}
rawCsv={rawCsv}
randomId={randomId}
/>
</QueryClientProvider>
);
};
Expand All @@ -62,6 +70,7 @@ const TableInner: React.FC<FlatUiTableProps> = ({
data,
rawCsv,
corsProxy,
randomId,
}) => {
if (data) {
return (
Expand All @@ -71,12 +80,12 @@ const TableInner: React.FC<FlatUiTableProps> = ({
);
}
const { data: csvString, isLoading: isDownloadingCSV } = useQuery(
['dataCsv', url],
['dataCsv', url, randomId],
() => getCsv(url as string, corsProxy),
{ enabled: !!url }
);
const { data: parsedData, isLoading: isParsing } = useQuery(
['dataPreview', csvString],
['dataPreview', csvString, randomId],
() => parseCsv(rawCsv ? (rawCsv as string) : (csvString as string)),
{ enabled: rawCsv ? true : !!csvString }
);
Expand Down

0 comments on commit 8e89613

Please sign in to comment.