Reputation: 2081
I am currently learning react and I have an app using webpack, babel and react. It seems react has two ways of writing it using either required
or import
. It also seems there is a lot more documentation on using import
. How can I change my stack to use the import version?
Upvotes: 1
Views: 1325
Reputation: 2133
import
is ES6 (or ES2015) standard. To use it, you need to install and activate the preset in babel.
Follow these steps:
npm install --save-dev babel-cli babel-preset-env
Create a file named .babelrc
(in case you have not created one) and insert this lines:
{
'presets': ['env', 'react']
}
I assume you have setup the webpack to work with babel.
Upvotes: 0