React-table version 7 all the data appears on One page - reactjs

I am trying to implement react-table
I have 750 rows and they all appear on the first page although I have controlled pagination that is telling me I am on page 1 of 68
But all the 750 rows - as I said - appear on one page .
All features are working, except for that issue.
I am fetching the data ( altogether ) from an API and sending them to the Table.
this is the code
import React from 'react';
import {
useSortBy,
useTable,
useGlobalFilter,
usePagination
} from 'react-table';
function Table({ columns, data }) {
const {
getTableProps,
getTableBodyProps,
headerGroups,
nextPage,
previousPage,
canNextPage,
canPreviousPage,
pageOptions,
gotoPage,
pageCount,
setPageSize,
rows,
prepareRow,
state,
setGlobalFilter
} = useTable(
{
columns,
data
},
useGlobalFilter,
useSortBy,
usePagination
);
const { globalFilter, pageIndex, pageSize } = state;
return (
<>
<GlobalFilter filter={globalFilter} setFilter={setGlobalFilter} />
<table {...getTableProps()}>
<thead>
{headerGroups.map((headerGroup) => (
<tr {...headerGroup.getHeaderGroupProps()}>
{headerGroup.headers.map((column) => (
<th {...column.getHeaderProps(column.getSortByToggleProps())}>
{column.render('header')}
<span>
{column.isSorted
? column.isSortedDesc
? ' 🔽'
: ' 🔼'
: ''}
</span>
</th>
))}
</tr>
))}
</thead>
<tbody {...getTableBodyProps()}>
{rows.map((row, i) => {
prepareRow(row);
return (
<tr {...row.getRowProps()}>
{row.cells.map((cell) => {
return (
<td {...cell.getCellProps()}>{cell.render('Cell')}</td>
);
})}
</tr>
);
})}
</tbody>
</table>
<div>
<span>
Page{' '}
<strong>
{pageIndex + 1} of {pageOptions.length}
</strong>
</span>
<span>
| Go to page
<input
type="number"
defaultValue={pageIndex + 1}
onChange={(e) => {
const pageNumber = e.target.value
? Number(e.target.value) - 1
: 0;
gotoPage(pageNumber);
}}
/>
</span>
<select
value={pageSize}
onChange={(e) => setPageSize(Number(e.target.value))}
>
{[10, 25, 50].map((pageSize) => (
<option key={pageSize} value={pageSize}>
Show {pageSize}
</option>
))}
</select>
<button onClick={() => gotoPage(0)} disabled={!canPreviousPage}>
{'<<'}
</button>
<button onClick={() => previousPage()} disabled={!canPreviousPage}>
Previous
</button>
<button onClick={() => nextPage()} disabled={!canNextPage}>
Next
</button>
<button onClick={() => gotoPage(pageCount - 1)} disabled={!canNextPage}>
{'>>'}
</button>
</div>
</>
);
}
const GlobalFilter = ({ filter, setFilter }) => {
return (
<span>
Search:{' '}
<input value={filter || ''} onChange={(e) => setFilter(e.target.value)} />
</span>
);
};
export default Table;

My bad
I should use page instead of rows
Like this
<tbody {...getTableBodyProps()}>
{page.map((row) => {
prepareRow(row);
return (
<tr {...row.getRowProps()}>
{row.cells.map((cell) => {
return (
<td
{...cell.getCellProps()}
className="p-2 border border-collapse"
>
{cell.render('Cell')}
</td>
);
})}
</tr>
);
})}
</tbody>

Related

Toggle icons in react after iterating through Object and update the form

I have a form with a social object, I want to add an icon to the social notification that has a boolean value and also want to toggle the icon and update the form.
export default function UserProfile(props) {
const form = useForm({
initialValues: {
name: props.userProfile.name,
socials: {
email: {
notifications: true,
},
facebook: {
notifications: false,
},
twitter: {
notifications: false,
},
},
},
});
return (
<>
<form
method="post"
className="pt-5"
key={props.userProfile.id}
onSubmit={form.onSubmit(handleSubmit)}
>
<TextInput
label="Name"
placeholder={props.userProfile.name}
{...form.getInputProps("name")}
/>
<Tabledata
socials={{ ...form.getInputProps("socials") }}
session={session}
/>
<button type="submit">Save</button>
</form>
</>
)
}
The table data component is :
function Tabledata({ socials }) {
// console.log(socials.value["email"]["notifications"]);
function ToggleButton() {
const [isChecked, setIsChecked] = useState(true);
return isChecked? <CheckCircleIcon
className="h-6 w-6 text-green-500"
onClick={() => setIsChecked(!isChecked)}
/>
: <XCircleIcon
className="h-6 w-6 text-red-500"
onClick={() => setIsChecked(!isChecked)}
/>
}
return (
<>
<Table>
<thead>
<tr>
<th>Social channel</th>
<th>Notifications</th>
</tr>
</thead>
<tbody>
{Object.keys(socials.value).map((data, index) => (
<tr key={index}>
<td>{data}</td>
<td>
{socials.value[data]["notifications"]? (
<ToggleButton />
) : (
"Null"
)}
</td>
</tr>
))}
</tbody>
</Table>
</>
);
}
But I'm unable to toggle the value of the notification. How can I approach that? I was trying the above method and also I tried the below method, but not getting the desired result. I'm not sure how to do that.
function Tabledata({ socials }) {
return (
<>
<Table>
<thead>
<tr>
<th>Social channel</th>
<th>Notifications</th>
</tr>
</thead>
<tbody>
{Object.keys(socials.value).map((data, index) => (
<tr key={index}>
<td>{data}</td>
<td>
{socials.value[data]["notifications"]? (
<CheckCircleIcon
className="h-6 w-6 text-green-500"
onClick={() =>
console.log(`change the notification to false`)
}
/>
) : (
<XCircleIcon
className="h-6 w-6 text-red-500"
onClick={() =>
console.log(`change the notification to true`)
}
/>
)}
</td>
</tr>
))}
</tbody>
</Table>
</>
);
}
Please leave you suggestions. I tried different StackOverflow suggestions but could not able to solve my problem.
I refactored your code, I think you are on the right track, your mistake is that you are creating a function toggleButton and you call the function like a component <toggleButton />, I just updated your code . I hope it works.
function Tabledata({ socials }) {
// console.log(socials.value["email"]["notifications"]);
const [isChecked, setIsChecked] = useState(true);
function toggleButton() {
return isChecked ? (
<CheckCircleIcon
className="h-6 w-6 text-green-500"
onClick={() => setIsChecked(false)}
/>
) : (
<XCircleIcon
className="h-6 w-6 text-red-500"
onClick={() => setIsChecked(true)}
/>
);
}
return (
<>
<Table>
<thead>
<tr>
<th>Social channel</th>
<th>Notifications</th>
</tr>
</thead>
<tbody>
{Object.keys(socials.value).map((data, index) => (
<tr key={index}>
<td>{data}</td>
<td>
{communications.value[data]["notifications"] ? (
<>{toggleButton()}</>
) : (
"Null"
)}
</td>
</tr>
))}
</tbody>
</Table>
</>
);
}
And if you want to make component, then you have to make the toggleButton func outside the TableData, as you can see the below code.
function ToggleButton() {
const [isChecked, setIsChecked] = useState(true);
return isChecked ? (
<CheckCircleIcon
className="h-6 w-6 text-green-500"
onClick={() => setIsChecked(!isChecked)}
/>
) : (
<XCircleIcon
className="h-6 w-6 text-red-500"
onClick={() => setIsChecked(!isChecked)}
/>
);
}
function Tabledata({ socials }) {
// console.log(socials.value["email"]["notifications"]);
return (
<>
<Table>
<thead>
<tr>
<th>Social channel</th>
<th>Notifications</th>
</tr>
</thead>
<tbody>
{Object.keys(socials.value).map((data, index) => (
<tr key={index}>
<td>{data}</td>
<td>
{communications.value[data]["notifications"] ? (
<ToggleButton />
) : (
"Null"
)}
</td>
</tr>
))}
</tbody>
</Table>
</>
);
}

useTable with useFilter - how to get exact number

i am using react-Table (useTable & useFilter) but the filter i created return results that "contain" the required number instead of the exact number i need.
for example:
original table:
age ==> 11,8,1
after filtering the age== 1 --> i receive:
age ==> 11,1
while i would like to receive the following (the exact age i asked for)
age ==> 1
how can i get the exact number needed and not list of numbers that contain the required number?
my code:
ColumnFilter component:
import React from 'react'
export const ColumnFilter = ({ column }) => {
const { filterValue, setFilter } = column
console.log('filterValue', filterValue)
return (
<span >
<input style={{width: '7rem', fontSize: '1.25 rem'}} value={filterValue || ''} onChange={e => setFilter(e.target.value)} />
</span>
)
}
Table component:
const Table = ({ columns, data}) => {
const defaultColumn = React.useMemo(
() => {
return {
Filter: ColumnFilter
}
},
[]
)
// the deafult sort column
const sortees = React.useMemo(
() => [
{
id: "id",
desc: true
}
],
[]
);
const {
getTableProps,
getTableBodyProps,
headerGroups,
prepareRow,
setAllFilters,
page, // Instead of using 'rows', we'll use page, which has only the rows for the active page (part of pagination process)
} = useTable(
{
columns,
data,
defaultColumn,
initialState: {
sortBy: sortees
}
},
useFilters,
useSortBy,
usePagination
);
return (
<>
<table className='tableDataInfo' {...getTableProps()}>
<thead>
{headerGroups.map((headerGroup) => {
return (
<tr className='tableData_tr' {...headerGroup.getHeaderGroupProps()}>
{headerGroup.headers.map((column, index) => {
return (
<th className='tableData_th'{...column.getHeaderProps({ style: { width: column.width } })}>
{column.render("Header")}
{/* ============= sort section ============= */}
<span {...column.getHeaderProps(column.getSortByToggleProps())}>
{column.isSorted ?
column.isSortedDesc ? <TiArrowSortedDown /> : column.isSortedDesc === false ? <TiArrowSortedUp /> : <TiArrowUnsorted />
: column.id !== "action" && column.id !== "costview"?
column.isSortedDesc ? <TiArrowSortedUp /> : column.isSortedDesc === false ? <TiArrowSortedDown /> : <TiArrowUnsorted />
: ""
}
</span>
{/* ============= information section ============= */}
<span className="new-tooltip" >
{headerGroup.headers[index].tipText ? <BsInfoCircle /> : ''}
{headerGroup.headers[index].tipText && (<span> {headerGroup.headers[index].tipText} </span>)}
</span>
{/* ============= add reset filter above the actions column ============= */}
<span >
{column.id === "action" ? <button className='unfilterButton' onClick={() => setAllFilters([])}><TbFilterOff /></button> : ''}
</span>
<br />
{/* ============= filter section ============= */}
<span className="filterContainer">
{/* <div>
{column.canFilter ? <button className='filterButton' onClick={() => handelFilter(headerGroup.headers[index])} ><VscFilter /> </button> : null}
</div> */}
<div>
{headerGroup.headers[index].canFilter ? headerGroup.headers[index].render('Filter') : ''}
</div>
</span>
</th>
);
})}
</tr>
);
})}
</thead>
<tbody className = 'tableofInfo' {...getTableBodyProps()}>
{page.map((row, i) => {
prepareRow(row);
return (
<tr className='tableData_tr' {...row.getRowProps(/*getTrProps*/)}>
{row.cells.map((cell) => {
return (
<td className='tableData_td'{...cell.getCellProps({ style: { width: cell.column.width } })}> {cell.render("Cell")}</td>
);
})}
</tr>
);
})}
</tbody>
</table>
<br />
</>
);
}
export default Table;

React-Table resetting to page 1 when I add data

I have a react table with pages that works with me adding new data to the collection however when ever data is added it always resets the current page to 0. Is there some way to save the current state of what page is currently selected? I cant figure out based of this code I have from a fellow what I need to change in order for this to not keep resetting the page index.
My table code looks like this
function Table({ columns, data }) {
const filterTypes = React.useMemo(
() => ({
// Add a new fuzzyTextFilterFn filter type.
fuzzyText: fuzzyTextFilterFn,
// Or, override the default text filter to use
// "startWith"
text: (rows, id, filterValue) => {
return rows.filter(row => {
const rowValue = row.values[id]
return rowValue !== undefined
? String(rowValue)
.toLowerCase()
.startsWith(String(filterValue).toLowerCase())
: true
})
},
}),
[]
)
const defaultColumn = React.useMemo(
() => ({
// Let's set up our default Filter UI
Filter: DefaultColumnFilter,
}),
[]
)
const {
getTableProps,
getTableBodyProps,
headerGroups,
rows,
prepareRow,
state,
visibleColumns,
preGlobalFilteredRows,
setGlobalFilter,
page,
canPreviousPage,
canNextPage,
pageOptions,
pageCount,
gotoPage,
nextPage,
previousPage,
setPageSize,
selectedPage,
state: { pageIndex, pageSize },
} = useTable(
{
columns,
data,
defaultColumn, // Be sure to pass the defaultColumn option
filterTypes,
initialState: { pageIndex: 0}
},
useFilters, // useFilters!
useGlobalFilter, // useGlobalFilter!
usePagination
)
// We don't want to render all of the rows for this example, so cap
// it for this use case
//const firstPageRows = rows.slice(0, 10)
return (
<>
<table {...getTableProps()}>
<thead>
{headerGroups.map(headerGroup => (
<tr {...headerGroup.getHeaderGroupProps()}>
{headerGroup.headers.map(column => (
<th {...column.getHeaderProps()}>
{column.render('Header')}
{/* Render the columns filter UI */}
<div>{column.canFilter ? column.render('Filter') : null}</div>
</th>
))}
</tr>
))}
</thead>
<tbody {...getTableBodyProps()}>
{page.map((row, i) => {
prepareRow(row)
return (
<tr {...row.getRowProps()}>
{row.cells.map(cell => {
return <td {...cell.getCellProps()}>{cell.render('Cell')}</td>
})}
</tr>
)
})}
</tbody>
</table>
<br />
{/*<div>Showing the first 20 results of {rows.length} rows</div>*/}
<div className="pagination">
<button onClick={() => gotoPage(0)} disabled={!canPreviousPage}>
{'<<'}
</button>{' '}
<button onClick={() => previousPage()} disabled={!canPreviousPage}>
{'<'}
</button>{' '}
<button onClick={() => nextPage()} disabled={!canNextPage}>
{'>'}
</button>{' '}
<button onClick={() => gotoPage(pageCount - 1)} disabled={!canNextPage}>
{'>>'}
</button>{' '}
<span>
Page{' '}
<strong>
{pageIndex + 1} of {pageOptions.length}
</strong>{' '}
</span>
<span>
| Go to page:{' '}
<input
type="number"
defaultValue={pageIndex}
onChange={e => {
const page = e.target.value ? Number(e.target.value) - 1 : 0
gotoPage(page)
}}
style={{ width: '100px' }}
/>
</span>{' '}
<select
value={pageSize}
onChange={e => {
setPageSize(Number(e.target.value))
}}
>
{[10, 20, 30, 40].map(pageSize => (
<option key={pageSize} value={pageSize}>
Show {pageSize}
</option>
))}
</select>
</div>
</>
)
}```
You might not need to save the current state of what page is currently selected. All you need to do is set autoselect option on your table to false.
Your code should look like this
function Table({ columns, data }) {
const filterTypes = React.useMemo(
() => ({
// Add a new fuzzyTextFilterFn filter type.
fuzzyText: fuzzyTextFilterFn,
// Or, override the default text filter to use
// "startWith"
text: (rows, id, filterValue) => {
return rows.filter(row => {
const rowValue = row.values[id]
return rowValue !== undefined
? String(rowValue)
.toLowerCase()
.startsWith(String(filterValue).toLowerCase())
: true
})
},
}),
[]
)
const defaultColumn = React.useMemo(
() => ({
// Let's set up our default Filter UI
Filter: DefaultColumnFilter,
}),
[]
)
const {
getTableProps,
getTableBodyProps,
headerGroups,
rows,
prepareRow,
state,
visibleColumns,
preGlobalFilteredRows,
setGlobalFilter,
page,
canPreviousPage,
canNextPage,
pageOptions,
pageCount,
gotoPage,
nextPage,
previousPage,
setPageSize,
selectedPage,
state: { pageIndex, pageSize },
} = useTable(
{
columns,
data,
defaultColumn, // Be sure to pass the defaultColumn option
filterTypes,
initialState: { pageIndex: 0},
autoResetPage: false, //this change should be made
},
useFilters, // useFilters!
useGlobalFilter, // useGlobalFilter!
usePagination
)
// We don't want to render all of the rows for this example, so cap
// it for this use case
//const firstPageRows = rows.slice(0, 10)
return (
<>
<table {...getTableProps()}>
<thead>
{headerGroups.map(headerGroup => (
<tr {...headerGroup.getHeaderGroupProps()}>
{headerGroup.headers.map(column => (
<th {...column.getHeaderProps()}>
{column.render('Header')}
{/* Render the columns filter UI */}
<div>{column.canFilter ? column.render('Filter') : null}</div>
</th>
))}
</tr>
))}
</thead>
<tbody {...getTableBodyProps()}>
{page.map((row, i) => {
prepareRow(row)
return (
<tr {...row.getRowProps()}>
{row.cells.map(cell => {
return <td {...cell.getCellProps()}>{cell.render('Cell')}</td>
})}
</tr>
)
})}
</tbody>
</table>
<br />
{/*<div>Showing the first 20 results of {rows.length} rows</div>*/}
<div className="pagination">
<button onClick={() => gotoPage(0)} disabled={!canPreviousPage}>
{'<<'}
</button>{' '}
<button onClick={() => previousPage()} disabled={!canPreviousPage}>
{'<'}
</button>{' '}
<button onClick={() => nextPage()} disabled={!canNextPage}>
{'>'}
</button>{' '}
<button onClick={() => gotoPage(pageCount - 1)} disabled={!canNextPage}>
{'>>'}
</button>{' '}
<span>
Page{' '}
<strong>
{pageIndex + 1} of {pageOptions.length}
</strong>{' '}
</span>
<span>
| Go to page:{' '}
<input
type="number"
defaultValue={pageIndex}
onChange={e => {
const page = e.target.value ? Number(e.target.value) - 1 : 0
gotoPage(page)
}}
style={{ width: '100px' }}
/>
</span>{' '}
<select
value={pageSize}
onChange={e => {
setPageSize(Number(e.target.value))
}}
>
{[10, 20, 30, 40].map(pageSize => (
<option key={pageSize} value={pageSize}>
Show {pageSize}
</option>
))}
</select>
</div>
</>
)}
The answer is found on this page of the docs

React-table global filter Regex

Having trouble getting my GlobalFilter to update the table when using Regex to search for multiple results in a column.
export const Table = ({ data, columns }) => {
const filterTypes = useMemo(
() => ({
// Override the default text filter to use
// "startWith"
text: (rows, id, filterValue) => {
return rows.filter((row) => {
const rowValue = row.values[id];
const isRegexMatch = () => {
try {
return RegExp(filterValue).test(String(rowValue));
} catch (err) {
return false;
}
};
return rowValue !== undefined
? String(rowValue)
.toLowerCase()
.startsWith(String(filterValue).toLowerCase()) || isRegexMatch()
: true;
});
},
}),
[]
);
const {
getTableProps,
getTableBodyProps,
headerGroups,
prepareRow,
page,
canPreviousPage,
canNextPage,
pageOptions,
pageCount,
gotoPage,
nextPage,
previousPage,
setPageSize,
preGlobalFilteredRows,
setGlobalFilter,
state,
state: { pageIndex, pageSize },
} = useTable(
{
columns,
data,
filterTypes,
},
useFilters,
useGlobalFilter,
useSortBy,
usePagination
);
return (
<div className="col-12">
<div className="table-responsive mb-5">
<GlobalFilter
preGlobalFilteredRows={preGlobalFilteredRows}
globalFilter={state.globalFilter}
setGlobalFilter={setGlobalFilter}
/>
<table {...getTableProps()} className="table">
<thead>
{headerGroups.map((headerGroup) => (
<tr {...headerGroup.getHeaderGroupProps()}>
{headerGroup.headers.map((column) => (
<th {...column.getHeaderProps(column.getSortByToggleProps())}>
{column.render('Header')}
<span>
{column.isSorted ? (
column.isSortedDesc ? (
<ChevronDown baseLayer="icon" />
) : (
<ChevronUp baseLayer="icon" />
)
) : (
''
)}
</span>
</th>
))}
</tr>
))}
</thead>
<tbody {...getTableBodyProps()}>
{page.map((row, i) => {
prepareRow(row);
return (
<tr {...row.getRowProps()} key={i}>
{row.cells.map((cell) => {
return (
<td {...cell.getCellProps()}>{cell.render('Cell')}</td>
);
})}
</tr>
);
})}
</tbody>
</table>
<div className="pagination mt-3">
<button
onClick={() => gotoPage(0)}
disabled={!canPreviousPage}
className="btn btn-sm btn-link"
>
{'<<'}
</button>{' '}
<button
onClick={() => previousPage()}
disabled={!canPreviousPage}
className="btn btn-sm btn-link"
>
{'<'}
</button>{' '}
<button
onClick={() => nextPage()}
disabled={!canNextPage}
className="btn btn-sm btn-link"
>
{'>'}
</button>{' '}
<button
onClick={() => gotoPage(pageCount - 1)}
disabled={!canNextPage}
className="btn btn-sm btn-link"
>
{'>'}
</button>{' '}
<span className="mt-2 text-muted">
<small>
Page {pageIndex + 1} of {pageOptions.length}{' '}
</small>
</span>
<span className="mt-2 ms-1 me-1 text-muted">
<small> | Go to page:</small>
</span>
<span className="me-1">
<input
type="number"
className="form-control"
defaultValue={pageIndex + 1}
onChange={(e) => {
const page = e.target.value ? Number(e.target.value) - 1 : 0;
gotoPage(page);
}}
style={{ width: '80px' }}
/>
</span>
<select
value={pageSize}
style={{ width: '190px' }}
className="form-control"
onChange={(e) => {
setPageSize(Number(e.target.value));
}}
>
{[10, 20, 30, 40, 50].map((pageSize) => (
<option key={pageSize} value={pageSize}>
Show {pageSize} per page
</option>
))}
<option key={data.length} value={data.length}>
Show All
</option>
</select>
</div>
</div>
</div>
);
};
I only had success so far in the console with this function being able to filter the results, but so far no luck with the react-table package.
function regexFilter(rows, ids, filterValue) {
rows = rows.filter((row) => {
return ids.some((id) => {
const rowValue = row.values[id];
const isRegexMatch = () => {
try {
return RegExp(filterValue).test(String(rowValue));
} catch (err) {
return false;
}
};
return (
String(rowValue)
.toLowerCase()
.includes(String(filterValue).toLowerCase()) || isRegexMatch()
);
});
});
return rows;
}
What am I not doing correctly or mis-interpreting from the documentation on filterTypes?

Word is not getting added until the page is refreshed in TableItem component in React

TableItem component added without any data in UI. Could somebody help on this. On refereshing the UI, added data is shown with details in TableItem component.
Table Component Code
import TableItem from "./TableItem";
function Table({ searchWord }) {
const dispatch = useDispatch();
const dictData = useSelector((state) => state.dictionary);
useEffect(() => {
dispatch(getDictionaryAsync());
}, [dispatch]);
return (
<table className="table table-striped">
<thead>
<tr>
<th scope="col">Word</th>
<th scope="col">Description</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
{dictData &&
dictData
.filter((e) =>
searchWord === ""
? e
: e.word &&
e.word.toLowerCase().includes(searchWord.toLowerCase())
)
.map((item) => (
<TableItem item={item} key={item.id} searchWord={searchWord} />
))}
</tbody>
</table>
);
}
export default Table;
Below is the TableItem Component Code which i am trying to update,
When i add a word to dictionary it will fetch the details from the server and display it in the React app.
function TableItem({ item }) {
const [modal, setModal] = useState(false);
const openModal = () => {
setModal(true);
};
return (
<>
<tr key={item.id}>
<td style={{ textTransform: "capitalize" }}>{item.word}</td>
<td>
<b style={{ textTransform: "capitalize" }}>
{item.items && item.items[0].category} -{" "}
</b>
{item.items && truncate(item.items[0].definitions[0])}
</td>
<td>
<button className="btn btn-danger btn-sm " onClick={openModal}>
View
</button>
</td>
</tr>
<Modal isOpen={modal} ariaHideApp={true}>
<div className="modal-header">
<h3 className="modal-word-header">
{item.word && item.word.toUpperCase()}
</h3>
<button
className="btn btn-danger btn-sm"
onClick={() => setModal(false)}
>
<i class="fa fa-times" aria-hidden="true"></i>
</button>
</div>
<div className="model-content">
<p>
{item.items &&
item.items.map((e) => {
return (
<>
<i>{e.category}</i>
<ul>
{e.definitions.map((def) => {
return <li>{def}</li>;
})}
</ul>
</>
);
})}
</p>
</div>
</Modal>
</>
);
}
Better add your TableItem component code!
Below code works fine and updated the UI on change in the Data in TableItem,
useEffect(() => {
dispatch(getDictionaryAsync());
}, [dispatch, dictData]); *<--updated code*

Resources