-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@react_component directive is not working ? #41
Comments
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! |
@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 ? |
Well, it should work like this... what |
@talyssonoc here is the my phpInfo details. V8 Javascript Engine enabled |
@mihirsoni, can you please change the source of <?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! |
@mihirsoni can you check this so I can close the issue or try to solve some other way? Also, can you try to run |
@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. |
Huuum, that's weird 😞. Did you try the |
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? |
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? |
btw did you try Flux? will it work with such structure? I was just going to check, but stumbled at component config. |
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! |
+1 I just cloned the example project, |
Hi ,
I have been trying since long to make it react-laravel work but it seems may be I am missing something, I have installed all the required dependencies after that I tried the demo project but still it didn't work,
https://github.com/talyssonoc/react-laravel-example
/Mihir
The text was updated successfully, but these errors were encountered: