change table on path change

This commit is contained in:
shams mosowi
2019-09-24 12:15:13 +10:00
parent 7ad1bf3ae3
commit 26225005be
2 changed files with 6 additions and 4 deletions

View File

@@ -1,4 +1,4 @@
import React, { useState } from "react";
import React, { useState, useEffect } from "react";
import ReactDataGrid from "react-data-grid";
import useFiretable from "../../hooks/useFiretable";
import { createStyles, Theme, makeStyles } from "@material-ui/core/styles";
@@ -36,7 +36,9 @@ const useStyles = makeStyles(Theme =>
function Table(props: any) {
const { collection } = props;
const { tableState, tableActions } = useFiretable(collection);
useEffect(() => {
tableActions.set(collection);
}, [collection]);
const classes = useStyles();
const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(null);

View File

@@ -12,7 +12,7 @@ export type FiretableActions = {
update: Function;
};
row: { add: any; delete: Function };
table: { set: Function };
set: Function;
};
export type FiretableState = {
@@ -48,7 +48,7 @@ const useFiretable = (collectionName: string) => {
remove: configActions.remove,
},
row: { add: tableActions.addRow, delete: tableActions.deleteRow },
table: { set: setTable },
set: setTable,
};
return { tableState: state, tableActions: actions };