You are browsing the Symfony 4 documentation, which changes significantly from Symfony 3.x. If your app doesn't use Symfony 4 yet, browse the Symfony 3.4 documentation.

Enabling React.js

4.1 version
Maintained Unmaintained

Enabling React.jsΒΆ

Using React? First enable support for it in webpack.config.js:

1
2
$ yarn add --dev @babel/preset-react
$ yarn add react react-dom prop-types

Enable react in your webpack.config.js:

1
2
3
4
5
6
7
// webpack.config.js
// ...

Encore
    // ...
+     .enableReactPreset()
;

Then restart Encore. When you do, it will give you a command you can run to install any missing dependencies. After running that command and restarting Encore, you're done!

Your .js and .jsx files will now be transformed through babel-preset-react.

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.