Fix race?

This commit is contained in:
Dominic Zimmer 2025-05-03 18:08:46 +02:00
parent 7438573c49
commit b42097f4b8

View File

@ -29,10 +29,13 @@ export const App : React.FC = () => {
const formSubmit = async () => {
const newst = addEntry(store, {variant: "eats", date: new Date().toString(), item: input} );
console.log("newstore is", newst);
await API.write(JSON.stringify(store))
API.write(JSON.stringify(store)).then(async () => {
setTimeout(async () => {
const fromserver = await API.read();
setStore({...fromserver} );
setInput("");
}, 150);
})
};
const [input, setInput] = useState<string>("");
@ -139,9 +142,11 @@ export const RenderTable : React.FC<{API: APIEndPoint, store: Store, setStore: (
if (isSelected) {
const newst = removeEntry(store, item );
console.log("newstore is", newst);
await API.write(JSON.stringify(store))
API.write(JSON.stringify(store)).then(async () => {
setTimeout(async () => {
const fromserver = await API.read();
setStore({...fromserver} );
}, 150);
}
}}
key={index} className="reacts"><td>{datestring}</td>