starknet-react
starknet-react copied to clipboard
`useStarknetCall` set `loading` to `false` before the data is actually loaded
In the useEffect of the useStarknetCall hook, we call dispatch({ type: 'set_last_updated_at', blockHash: block.block_hash }) without waiting the refresh to finalize.
Which leads to set loading (and maybe lastUpdatedAt) to early.
https://github.com/apibara/starknet-react/blob/883cba7b7188201ab27baccf75f3569a3eec4cc3/packages/core/src/hooks/call.ts#L119-L120
- In think we should only allow the dispatch types
set_call_responseandset_call_errorto be able to set theloadingproperty. - Also, maybe we should only set the
lastUpdatedAtproperty when the new data are loaded properly.