Ad

React In WebPack

- 1 answer

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?

Ad

Answer

It should be like,

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

ReactDOM.render(...);
Ad
source: stackoverflow.com
Ad