0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-27 21:39:16 -05:00

fix(console): avoid rendering outdated role options (#5953)

This commit is contained in:
Xiao Yijun 2024-05-31 13:09:09 +08:00 committed by GitHub
parent 0b5b15b969
commit b8ea4800c5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -45,7 +45,14 @@ function SourceRolesBox({ entityId, type, selectedRoles, onChange }: Props) {
...conditional(keyword && { search: `%${keyword}%` }),
});
const { data, error } = useSWR<[RoleResponse[], number], RequestError>(url);
const { data, error } = useSWR<[RoleResponse[], number], RequestError>(url, {
/**
* Always use the latest data to reflect the latest available roles.
* Using cached data before new data is loaded can result in roles that have been assigned or deleted being rendered in the list.
* If a deleted role is rendered in the list, it will cause the query requests for role scopes in the list items to return a 404 error.
*/
keepPreviousData: false,
});
const isLoading = !data && !error;