Skip to main content

You can use ProvidePluginProvidePlugin to automatically require React when needed.

Just add to your webpack config file:

var webpack = require('webpack'); module.exports = { // Your configuration stuff. plugins: [ new webpack.ProvidePlugin({ React: 'react' }) ] }; 

Every time React is used in a file it will be auto-required/imported without having to do it explicitly.

You can use ProvidePlugin to automatically require React when needed.

Just add to your webpack config file:

var webpack = require('webpack'); module.exports = { // Your configuration stuff. plugins: [ new webpack.ProvidePlugin({ React: 'react' }) ] }; 

Every time React is used in a file it will be auto-required/imported without having to do it explicitly.

You can use ProvidePlugin to automatically require React when needed.

Just add to your webpack config file:

var webpack = require('webpack'); module.exports = { // Your configuration stuff. plugins: [ new webpack.ProvidePlugin({ React: 'react' }) ] }; 

Every time React is used in a file it will be auto-required/imported without having to do it explicitly.

Source Link
dreyescat
  • 13.9k
  • 5
  • 52
  • 38

You can use ProvidePlugin to automatically require React when needed.

Just add to your webpack config file:

var webpack = require('webpack'); module.exports = { // Your configuration stuff. plugins: [ new webpack.ProvidePlugin({ React: 'react' }) ] }; 

Every time React is used in a file it will be auto-required/imported without having to do it explicitly.