Vladimir37 Vladimir37 - 1 year ago 106
Javascript Question

React in WebPack

I join JS-files through WebPack. In config introduced all files.

entry: ['./file1', './file2', 'react', 'react-dom']

React and React-dom downloaded through npm. If in file I call React, returns error:

ReferenceError: React is not defined

But if I write

import {React} from 'react';

returns error

TypeError: _react.React is undefined

What am I doing wrong?

Answer Source

It should be like,

import React from 'react';
import ReactDOM from 'react-dom';

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download