Fix race?
This commit is contained in:
parent
7438573c49
commit
b42097f4b8
@ -29,10 +29,13 @@ export const App : React.FC = () => {
|
|||||||
const formSubmit = async () => {
|
const formSubmit = async () => {
|
||||||
const newst = addEntry(store, {variant: "eats", date: new Date().toString(), item: input} );
|
const newst = addEntry(store, {variant: "eats", date: new Date().toString(), item: input} );
|
||||||
console.log("newstore is", newst);
|
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();
|
const fromserver = await API.read();
|
||||||
setStore({...fromserver} );
|
setStore({...fromserver} );
|
||||||
setInput("");
|
setInput("");
|
||||||
|
}, 150);
|
||||||
|
})
|
||||||
};
|
};
|
||||||
const [input, setInput] = useState<string>("");
|
const [input, setInput] = useState<string>("");
|
||||||
|
|
||||||
@ -139,9 +142,11 @@ export const RenderTable : React.FC<{API: APIEndPoint, store: Store, setStore: (
|
|||||||
if (isSelected) {
|
if (isSelected) {
|
||||||
const newst = removeEntry(store, item );
|
const newst = removeEntry(store, item );
|
||||||
console.log("newstore is", newst);
|
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();
|
const fromserver = await API.read();
|
||||||
setStore({...fromserver} );
|
setStore({...fromserver} );
|
||||||
|
}, 150);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
key={index} className="reacts"><td>{datestring}</td>
|
key={index} className="reacts"><td>{datestring}</td>
|
||||||
|
Loading…
Reference in New Issue
Block a user