Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type in React Typescript

$
0
0

I am using Typescript in my React-native project.Code working properly as per desired output.but getting typescript conflicts.

Sharing my code snippets

Importing json object from other config files.

import api from 'config/api.json'
  languageSet = async (value: string) => {  setStorageItem('language', value)  this.setState({ setLoading: true })  const language = await getStorageItem('language');  if (language) {    const baseURL = api[language][environment] ? api[language][environment].api : api[language].qa.api;  }  else {    const baseURL = api.ch[environment] ? api.ch[environment].api : api.ch.qa.api;  }}

I want to make dynamic baseURl that's why using language const to set it's value.
Following error I am facing.

enter image description here


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>