Search code examples
intellij-ideareactjsreact-nativeecmascript-6

Intellij IDEA cannot resolve React Native import


enter image description here

The React import is ok, but other import can not used in autocompletion.

If I import as import Text from 'react-native', this can be resolve correctly, but this is incorrect import.So I assume IDE will resolve symbol by lookup import Class name only, The question is how can I work around this ?


Solution

  • The problem occurs because of a tricky way react-native modules are defined. I'd suggest using typescript community stubs to solve the issue: Preferences | Languages & Frameworks | JavaScript | Libraries, press Download, then choose 'react-native' from the stubs list