How to create a dynamically changing table using NextUI? #2192
Unanswered
sgoldcreatives
asked this question in
Help
Replies: 2 comments 3 replies
-
FWIW discussions are here: #2193 |
Beta Was this translation helpful? Give feedback.
0 replies
-
Took me a while to figure this out too, had to go for a weird solution but it now works. const [randomKey, setRandomKey] = useState(Math.random());
const refreshTable = () => {
setRandomKey(Math.random())
}
const filteredItems = React.useMemo(() => {
let filteredUnlockers: any[] = unlockerData;
if (hasSearchFilter) {
filteredUnlockers = filteredUnlockers.filter((unlocker) =>
unlocker.title.toLowerCase().includes(filterValue.toLowerCase()),
);
}
if (statusFilter !== "all" && Array.from(statusFilter).length !== statusOptions.length) {
filteredUnlockers = filteredUnlockers.filter((unlocker) =>
Array.from(statusFilter).includes(unlocker.status),
);
}
return filteredUnlockers;
}, [users, filterValue, statusFilter, randomKey]); Notice that for the useMemo dependency array I added a useState variable "randomKey". Might be helpful for someone in the future |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
So I have no problem displaying the table using arrays and such. My problem is that I have a user input
weight
that I want to affect a table itemdosage
the problem is that I think that NextUI only renders the table once, therefore ifweight
changes after runtime, it does not affectdosage
.Beta Was this translation helpful? Give feedback.
All reactions