0

My application loads data from REST api as array of JSON objects. Application is a mix of standard UI with map capabilities, so each object contains standard fields as well as geometry as WKT.

interface Zone {
    id: number;
    name: string;
    geometry: string;
}

Whole loading loop looks like this:

  • user enters route myfrontendapp.com/ports/:portId/zones. He would like to see zones for port with :portId,
  • frontend sends GET request and receives data in Zone[] format,
  • zones: Zone[] gets mapped so new React component is created for every zone,
  • inside every newly created React component, useEffect(()=> loadingLogic(), []) loads geometry from zone.geometry using new WKT() and adds it to proper map source so it can be displayed

I noticed that there is slight delay before features load into the map. Whole app is completly unoperatable meaning browser doesn't respond to any events and everything just freezes. It is not a long delay because it is only ~100ms but it has very strong impact on UX.

Is there a way to somehow load these features asynchronously? I'd be willing to give up loading time (it could even load 5x slower) for the sake of app being operatable while its loading features.

2
  • There is no way to load features asynchronously unfortunately. If you post your loadingLogic code, we can take a look. In addition, if possible, avoid using WKT format as there will be a perfomance hit for doing this. Lastly, how much data are you loading in one go?
    – Eoin
    Commented Jul 26, 2022 at 8:10
  • @Eoin which format would be the fastest? I actually thought that WKT would be the fastest one and I intentionally convert GeoJSON coming from the database to WKT on my backend. Speaking about how much data - it is about 50 features. I think I figured it out anyways. After building and deploying app it works fine - it is instant Commented Jul 26, 2022 at 8:17

1 Answer 1

0

So I am not entirely sure why that happens but it just works slow in React's dev environment.

After building app and serving it directly from dist it works blazingly fast.

(I think it still would be cool to somehow be able to load things asynchronously)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.