react-simple-maps icon indicating copy to clipboard operation
react-simple-maps copied to clipboard

Handling of input geographies may need improvement?

Open payamazadi opened this issue 5 years ago • 0 comments

Right now if you want to implement the maps, we have:

<Geographies geography={url}> or maybe <Geographies geography={someObject}>

And when I check the code in the component, it ends up here:

if (isString(geography)) { fetchGeographies(geography).then(geos => { if (geos) setGeographies(getFeatures(geos, parseGeographies)) }) } else { setGeographies(getFeatures(geography, parseGeographies)) }

Is this the best implementation? It means that at the time I go to render the component I must already know the URL I'm going to use or have resolved the data object to pass in. But as a user I can't make this guarantee.

Maybe the code needs to be improved to also receive and handle a Promise, or something like that.

The goal would be that in my code I can use componentDidMount to resolve the data I need, place it in the state, and then pass in the state key to the component when I go to render.

Or am I thinking about this wrong?.. Any help would be appreciated..

payamazadi avatar Apr 05 '20 23:04 payamazadi