Comments (13)
Hi, @mihirsoni, some users are having a issue with the directive, as you can see in @nrcook's answer here: #28 (comment)
You can use the facade directly until I (or somebody else that send a PR) fix it, I hope it works for you!
from react-laravel.
@talyssonoc Hey , I tried to use the same but it doesn't run and give us segementation fault, do we need to add any extra configs for the same ?
from react-laravel.
Well, it should work like this... what V8Js
version are you using?
from react-laravel.
@talyssonoc here is the my phpInfo details.
V8 Javascript Engine enabled
V8 Engine Compiled Version 4.6.0
V8 Engine Linked Version 4.6.0 (candidate)
Version 0.2.1
from react-laravel.
@mihirsoni, can you please change the source of vendor\talyssonoc\react-laravel\lib\ReactServiceProvider.php
to this and check if it works:
<?php namespace React;
use Illuminate\Support\ServiceProvider;
class ReactServiceProvider extends ServiceProvider {
public function boot() {
$blade = $this->app->make('view')->getEngineResolver()
->resolve('blade')->getCompiler();
$blade->extend(function($view) {
$pattern = $this->createMatcher('react_component');
return preg_replace($pattern, '<?php echo React::render$2; ?>', $view);
});
$this->publishes([
__DIR__ . '/../assets' => public_path('vendor/react-laravel'),
], 'assets');
$this->publishes([
__DIR__ . '/../config/config.php' => config_path('react.php'),
], 'config');
}
public function register() {
$this->app->bind('React', function() {
if($this->app->environment('production')
&& $this->app->make('cache')->has('reactSource')
&& $this->app->make('cache')->has('componentsSource')) {
$reactSource = $this->app->make('cache')->get('reactSource');
$componentsSource = $this->app->make('cache')->get('componentsSource');
}
else {
$this->mergeConfigFrom(__DIR__ . '/../config/config.php', 'react');
$reactSource = file_get_contents(config('react.source'));
$componentsSource = file_get_contents(config('react.components'));
if($this->app->environment('production')) {
$this->app->make('cache')->forever('reactSource', $reactSource);
$this->app->make('cache')->forever('componentsSource', $componentsSource);
}
}
return new React($reactSource, $componentsSource);
});
}
protected function createMatcher($function) {
return '/(?<!\w)(\s*)@' . $function . '(\s*\(.*\))/';
}
}
Tell me if it does work, so I can put it in master branch!
from react-laravel.
@mihirsoni can you check this so I can close the issue or try to solve some other way? Also, can you try to run php artisan view:clear
and see if the component does render?
from react-laravel.
@talyssonoc, I checked with ReactServiceProvider code replacement - no result. I have similar situation, V8 installed and works well, {!! React::render('Message', [ 'name' => 'Hue' ], [ 'prerender' => true ]) !!} works fine, but @react_component('Message', ['name' => 'Hue']) doesn't renders.
I have simple nginx + php-fpm stack insalled on Yosemite (and Ubuntu at hosting side) w/o Homestead.
from react-laravel.
Huuum, that's weird 😞. Did you try the php artisan view:clear
?
from react-laravel.
Yep, I tried all of guessed manipulation throw the related issues, but ain't get result. How can I help? Where I should look for? At least simple blade call of {!! React::render(...) !!} works. Any suggestion?
from react-laravel.
For some reason the directive is not being registered (some that tested said that the code do not pass inside the closure of the registering of the directive), I never passed by this before, do you know some reason for it to happen?
from react-laravel.
btw did you try Flux? will it work with such structure? I was just going to check, but stumbled at component config.
from react-laravel.
I didn't tried yet, but I see no reason for Flux don't work, it just renders components on the server, if you use some lib that allows application bootstraping (like Alt) I guess it would work!
from react-laravel.
+1 I just cloned the example project, {!! React::render('Message', [ 'name' => 'Hue' ]) !!}
was the only way I could get it to work.
from react-laravel.
Related Issues (20)
- V8Js::executeString():1: TypeError: Cannot call method 'renderToString' of undefined HOT 1
- Construct ReactJS only when needed. HOT 1
- composer minimum-stability HOT 1
- v8js on Laravel Homestead with php7 HOT 8
- Multiple react apps within single laravel instance HOT 2
- 'prerender' => false is not working HOT 15
- Syntax error HOT 4
- configuring jsx
- Configuring HOT 4
- undefined:13: ReferenceError: document is not defined HOT 12
- Usage with redux
- is this still alive? HOT 2
- NPM Install Issue
- Minimum stability problem HOT 1
- Minimum Version of Laravel HOT 1
- Guide for Laravel for REST API only
- ComposerAutoloaderInit error HOT 1
- update
- Error Fetching Data in React Native with Laravel as a Back-End
- React router best practice
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-laravel.