Nisha Patel
Problem
I'm rather new to react/JS therefore this question may sound somehow dumb:
I need multiple variables that are set depending on a location(System variable). Those variables should be constants as they should never change for a given instance.
This is my current solution, it works but it feels very wrong to define variables inside other variable declarations. It also seems to not be possible to declare footerWidth and footerAltText as constants without an initial value.
Those attributes are provided by my features.ts:
One solution would be to make 3 switch-case configurations for the 3 variables, but that would lead to a lot of duplicated code...
Is there a proper way to do this?
Solution
Here's an approach using >array destructuring
You can use object destructuring as well
Suggested blogs:
>Why Typescript does not allow a union type in an array?
>Narrow SomeType vs SomeType[]
>Create a function that convert a dynamic Json to a formula in Typescript
>How to destroy a custom object within the use Effect hook in TypeScript?
>How to type the values of an object into a spreadsheet in TypeScript?
>Type key of record in a self-referential manner in TypeScript?
>How to get the last cell with data for a given column in TypeScript?
>Ignore requests by interceptors based on request content in TypeScript?
>Create data with Typescript Sequelize model without passing in an id?
>How to delete duplicate names from Array in Typescript?