Fix logic bug
This commit is contained in:
parent
3721f4ba5a
commit
b8c58ff1f5
@ -32,7 +32,8 @@ export function FamiliesListRoute(): React.ReactElement {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<AsyncWidget
|
<AsyncWidget
|
||||||
loadKey={loadKey.current}
|
ready={families !== null}
|
||||||
|
loadKey={`families-list-${loadKey.current}`}
|
||||||
load={load}
|
load={load}
|
||||||
errMsg="Echec du chargement de la liste des familles"
|
errMsg="Echec du chargement de la liste des familles"
|
||||||
build={() => (
|
build={() => (
|
||||||
|
@ -12,6 +12,7 @@ export function AsyncWidget(p: {
|
|||||||
load: () => Promise<void>;
|
load: () => Promise<void>;
|
||||||
errMsg: string;
|
errMsg: string;
|
||||||
build: () => React.ReactElement;
|
build: () => React.ReactElement;
|
||||||
|
ready?: boolean;
|
||||||
}): React.ReactElement {
|
}): React.ReactElement {
|
||||||
const [state, setState] = useState(State.Loading);
|
const [state, setState] = useState(State.Loading);
|
||||||
|
|
||||||
@ -35,7 +36,7 @@ export function AsyncWidget(p: {
|
|||||||
load();
|
load();
|
||||||
});
|
});
|
||||||
|
|
||||||
if (state === State.Loading)
|
if (state === State.Loading || p.ready === false)
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
@ -73,6 +74,6 @@ export function AsyncWidget(p: {
|
|||||||
<Button onClick={load}>Réessayer</Button>
|
<Button onClick={load}>Réessayer</Button>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
console.log(p, counter.current);
|
||||||
return p.build();
|
return p.build();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user