Lukas
Lukas

Reputation: 10360

React does not export its components via ES6 so IntelliJ throws warnings

I am writing a React app using ES6 like so

import React, { Component } from 'react';

I have installed react via npm, business as usual

npm install react --save-dev

It seems though that React is written using CommonJs as

module.exports = React;

so IntelliJ (or WebStorm) will throw a warning

default export is not declared in imported module

which is kind of bugging me and also autocompletion won't work. Does anyone have a solution for this?

Upvotes: 1

Views: 2321

Answers (2)

Jim Bockerstette
Jim Bockerstette

Reputation: 67

I am using Webstorm 2016.2. I don't know how to fix the warning but I was able to disable it. Use Alt-Enter and accept the fix. Here is the fix, notice the comment, that is the fix.

//noinspection TypeScriptCheckImport
import template from './app.html';

Upvotes: 2

lena
lena

Reputation: 93778

Though WEB-19542 is not yet fixed, I can't see this error reported for React in WebStorm 12 RC; Ctrl+click on it opens node_modules\react\react.js

Upvotes: 1

Related Questions