React Tips

How to import const from other modules

A good rule is to keep all constants in a separate file, away from all Views.

Try creating a file for all App Constants. Constants.js is a good choice.

Then put constants in like this:

1
2
3
4
5
6
const Constants = {
  AZURE_BLOB_CONTAINER: 'gisdatacontainer',
  ARCGIS_USERNAMER: 'user',
  ARCGIS_PORTAL: 'https://www.arcgis.com/portal'
}
export default Constants

Then you can import your constants wherever you need them.

1
import Constants from '../src/Constants'

and use like such

1
const user = Constants.ARCGIS_USERNAMER

Issue list

Date: 2021-03-30

如果 Azure Blob container文件过多,目录层级过多,用list blob操作,会导致下拉列表载入速度变慢。

写程序需要考虑性能影响。

When read all files from Azure Blob container as dropdown items, setItems using React hook. If there are a lot of files in Azure Blob container, the rendering speed of Select componet is very slow.

It is better replace the Select by a tree view in the page.

1
2
3
export AZCOPY_CRED_TYPE=Anonymous;
./azcopy remove "https://gisstoragedev.blob.core.windows.net/testcontainer/ipr/Yemen_Final_1-1.jp2?se=2021-04-30T17%3A48%3A48Z&sp=rdl&sv=2018-03-28&sr=c&sig=<Sig>" --recursive;
unset AZCOPY_CRED_TYPE;