Fix logic bug
This commit is contained in:
parent
3721f4ba5a
commit
b8c58ff1f5
@ -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={() => (
|
||||
|
@ -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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user