mimicreative / yii2-react
ReactJS Asset Bundle for Yii2
Installs: 360
Dependents: 0
Suggesters: 0
Security: 0
Stars: 13
Watchers: 5
Forks: 11
Open Issues: 0
Type:yii2-extension
Requires
- bower-asset/react: >=15.0.0
- yiisoft/yii2: >=2.0.0
This package is not auto-updated.
Last update: 2024-12-21 20:46:45 UTC
README
Installation
The preferred way to install this extension is through composer.
Add to the require section of your composer.json
file:
"mimicreative/yii2-react": "~1.0"
And run in terminal
composer update
Usage
Use as the asset bundle in Yii2 View files.
// use this if you do not need addons
\mimicreative\react\ReactAsset::register($this);
// use this if you need addons
\mimicreative\react\ReactWithAddonsAsset::register($this);
By default, this extension use the minified version. I also include the
react-dom.min.js
because we usually need it to render in js files.
To customize what asset to use, you can set the configuration in the Yii2 config
files. Please refer to React Bower package
for the list of the files.
For example if you want to use non-minified version:
// in main.php config file
return [
'components' => [
'assetManager' => [
'bundles' => [
'mimicreative\react\ReactAsset' => [
'js' => [
'react.js',
'react-dom.js'
]
],
'mimicreative\react\ReactWithAddonsAsset' => [
'js' => [
'react-with-addons.js',
'react-dom.js'
]
]
]
]
]
];
Further Information
Please, check the React.js site documentation for further information about its configuration options.