WebStorm auto import from react-native-web instead of from react-native for Image

Viewed 381

enter image description here

I am new to RN development. I am not entirely sure what should be imported from where.

Could someone explain

  1. How react-native-web/Image is different from react-native/Image?
  2. How do I default the auto-import option from react-native-web to react-native (Is that's necessary)?
1 Answers

This happens because you have react-native-web in your project's dependencies - the IDE suggests you symbols from this module in code completion and adds imports for them. As a workaround, please add react-native-web/**/* to the Do not import from list in Preferences | Editor | Code Style | JavaScript - Imports.

It's not quite clear why it doesn't suggest imports from react-native; what IDE version do you use? WEB-35144 is fixed in 2021.1

Related