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 ( 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={() => (

View File

@ -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();
} }