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

Resolving ts(2339) for react-native hooks for useState

$
0
0

I'm using useState in my react-native app as such:

const [loginDetails, setLoginDetals] = useState({});

When I try to access a property of loginDetails, I get a ts(2339) error from eslint:

enter image description here

I don't really have any interfaces or classes set up for this, but it does get populated with those fields. They are just not explicitly defined.

My eslint and prettier configs are as follows:

eslint

{"extends": ["airbnb", "prettier"],"plugins": ["prettier"],"rules": {"prettier/prettier": ["error"],"no-console": "off","func-names": "off","no-underscore-dangle": "off","no-unused-vars": "warn"  },"overrides": [    {"files": ["*.ts", "*.tsx"],"extends": ["airbnb","prettier","airbnb-typescript","prettier/@typescript-eslint"      ],"plugins": ["prettier", "@typescript-eslint"],"parser": "@typescript-eslint/parser"    }  ]}

prettier

{"tabWidth": 4,"printWidth": 200,"singleQuote": true,"endOfLine": "auto","trailingComma": "all"}

This error does not cause any compile or runtime issues, but I'd still like to fix it.

What's the proper way to handle it?


Viewing all articles
Browse latest Browse all 6287

Trending Articles



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