Skip to content

Idiomatically update state after fetching orderbook data #79

@secretshardul

Description

@secretshardul

Currently context/Dex.ts and context/Token.ts use a hacky approach to update state.

const [refresh, setRefresh] = useState(0);

A useState hook explicitly for refreshing is used after new values for _ORDERBOOK_CACHE are fetched via websockets. Ideally the orderbook data itself should be stored in useState(); that way updating this value will automatically refresh the UI.

Secondly there's double fetching of same data

  1. Websocket listens to changes in bid or asks, then calls setRefesh(). The fetched value is discarded, the only purpose of this was to update the UI again.
  2. The bid and ask data is fetched again using a useAsync hook

This should be resolved by the mentioned solution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions