How to store Configuration file and read it using React

前端 未结 4 776
执念已碎
执念已碎 2020-11-28 01:39

I am new on react.js I have implemented one component in which I am fetching the data from server and use it like,

CallEnterprise:function(TenantId){


             


        
4条回答
  •  无人及你
    2020-11-28 02:03

    If you used Create React App, you can set an environment variable using a .env file. The documentation is here:

    https://facebook.github.io/create-react-app/docs/adding-custom-environment-variables

    Basically do something like this in the .env file at the project root.

    REACT_APP_NOT_SECRET_CODE=abcdef
    

    You can access it from your component with

    process.env.REACT_APP_NOT_SECRET_CODE
    

提交回复
热议问题