react-nativeautocompleteidewebstormauto-import

WebStorm auto complete & auto import are not working


I work on React-Native in WebStorm.

Problem 1

I have some class, I want use auto import function of WebStorm, It works for some classes, but not for all.

When I type name and hit Ctrl + Space, it does not auto import class.

No import suggestion

I tried Alt + Enter also, it has no import suggestion in list.

no imports

Problem 2

Then I manually imported the class, now WebStorm is not able to show methods suggestion with auto complete, when I press Ctrl + Space, my methods are not listed there.

image3

Utility.js

export function alertMessage(alertMessage) {
  Alert.alert(
    "Alert",
    alertMessage,
    [{ text: "OK", onPress: () => console.log("OK Pressed") }],
    { cancelable: false }
  );
}

Is there some setting of WebStorm I am missing. I want to improve my productivity.


Solution

  • You are exporting your function using named export syntax (export function alertMessage()), but importing it as default, aliasing it to Utility; the IDE can't know what Utility is, thus no completion/autoimport is provided. Either change your export to default, or import your function using named import syntax