Ive been searching online for a method that refreshed the browser but I cant find anything and Im wondering if its even possible. I have a table that the user can update but when its updated the changes dont show. Any info about browser refreshing would be super helpful or maybe an alternate route for handling my problem:
this is my parent component:
const UserList = ({}) => {
const [list, setList] = useState([]);
const [errors, setErrors] = useState();
const [showPopUp, setShowPopUp] = useState(false);
const [permission, setPermission] = useState();
const [adminID, setAdminID] = useState();
const [successM, setSuccessM] = useState();
useEffect(() => {
api.UserManagement.list()
.then((result) => {
let list = [];
if (result) {
list = result.items;
}
setList(list);
})
.catch((err) => {
if (err.status) {
console.log("error", err, err.status);
setErrors([err]);
}
});
}, []);
const adminUpdate = async (perm, id) => {
console.log(perm, id);
if (!perm || !id) {
return;
} else {
try {
const result = await api.UserManagement.put(id, { permissions: [perm] })
const tempList = (list || []).map((item) => {
console.log(list)
if(item.id = id) {
item.permissions = [perm]
}
return item;
})
}catch (e) {
console.log("error", e)
}
}
};
return (
<>
{showPopUp && (
<RolePopUp
showPopUp={showPopUp}
setShowPopUp={setShowPopUp}
adminUpdate={adminUpdate}
adminID={adminID}
setPermission={setPermission}
setSuccessM={setSuccessM}
/>
)}
.....
//where the table is sent the list of users to use
<tbody>
{!list ? (
<PageLoadSpinner />
) : (
list.map((item, idx) => (
<UserCard
key={idx}
item={item}
setShowPopUp={setShowPopUp}
showPopUp={showPopUp}
adminUpdate={adminUpdate}
setAdminID={setAdminID}
permission={permission}
/>
))
)}
</tbody>
</Table>
</ContentRow>
)
Im hoping to add my refresh browser method inside the try catch statement in the parent component if the api call succeeds then refresh the browser if not then render an error.I can show the child components if needed.