Skip to main content

Code improvements

In case you want to improve your code and its maintainability, you can change the way you store variables. If you have variables that are global as for example “baseUrl” you can store them in the .env (or corresponding .env.development) Files. For development you can enter the variables into the “dev”-File and for the live version you can insert them into the parent file.
By defining your variable in one place it is easier to maintain the code further down the line in case you need to change the “baseUrl” for example or need to access multiple times the same hard coded variable. With the .env.development you can also always be sure that when you start a project locally you aren't accidantely sending request to the wrong organizer or comparable mistakes.

It needs to be noted that it is standard that any self-created global variable that they begin with a “REACT_APP_” and then have the appending variable name. These variables also need to be written in all caps so that react projects finds the variable during launching, be it for development or production.

.env.development File

We have also added an example of a page accessing the stored variable, the shown example is of the page Home.js.

All the displayed information has been put together by the Developmentteam. This page is here to help 3rd party users to impement our system correctly.