Fix logic bug

This commit is contained in:
Pierre HUBERT 2023-06-27 19:03:39 +02:00
parent 3721f4ba5a
commit b8c58ff1f5
2 changed files with 5 additions and 3 deletions

View File

@ -32,7 +32,8 @@ export function FamiliesListRoute(): React.ReactElement {
return (
<AsyncWidget
loadKey={loadKey.current}
ready={families !== null}
loadKey={`families-list-${loadKey.current}`}
load={load}
errMsg="Echec du chargement de la liste des familles"
build={() => (

View File

@ -12,6 +12,7 @@ export function AsyncWidget(p: {
load: () => Promise<void>;
errMsg: string;
build: () => React.ReactElement;
ready?: boolean;
}): React.ReactElement {
const [state, setState] = useState(State.Loading);
@ -35,7 +36,7 @@ export function AsyncWidget(p: {
load();
});
if (state === State.Loading)
if (state === State.Loading || p.ready === false)
return (
<div
style={{
@ -73,6 +74,6 @@ export function AsyncWidget(p: {
<Button onClick={load}>Réessayer</Button>
</div>
);
console.log(p, counter.current);
return p.build();
}