-
Notifications
You must be signed in to change notification settings - Fork 19
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
Calling Volt::mount a second time negates initial call #87
Comments
Thanks. Please provide thorough steps to reproduce this with code examples. |
@driesvints Thank you for reviewing the issue. I've updated the steps with more complete examples, and included a link to an example-repo. |
Here is an example workaround I've used: trait MergesVoltMounts
{
/**
* Merge the given paths with the existing Volt mounts.
*/
protected function mergeVoltMounts(array $paths): void
{
$voltPaths = collect(Volt::paths())->map(function ($path) {
return $path->path;
})->toArray();
$paths = array_merge($voltPaths, $paths);
Volt::mount($paths);
}
} |
Hi @inmanturbo. Thanks for the good example. This indeed doesn't seem possible. One solution packages can take for now is to ask app developers to add the paths to the |
This worked. Is it reliable ? MyPackageServiceProvider.php public function register()
{
....
$this->app->booted(function () {
$paths = collect(Volt::paths())->map->path->all();
$paths = array_merge($paths, [__DIR__ . '/../resources/views/livewire']);
Volt::mount($paths);
});
....
} |
@robsontenorio to a certain extent it is. If somehow there's a later call to |
@inmanturbo Do you have a better definitive solution? |
Short of a PR or something like #88, no. Aside from writing an install command for the components, or simply using vanilla Livewire. |
@robsontenorio and @inmanturbo I opened #95 which provides the same behavior as #88 but with a simpler solution. |
Thanks @bookwyrm 🙏 |
@bookwyrm yeah much simpler. Thank you! |
Volt Version
1.3
Laravel Version
10.31.0
PHP Version
8.3.1
Database Driver & Version
No response
Description
Calling
Volt::mount()
more than once overwrites the first call. This makes it impossible for packages to useVolt::mount()
to register their own components.Steps To Reproduce
Install volt. Add code above to Volt service provider. Run
php artisan make:volt counter
. Use counter component in view.Run the command below to copy the component to a new component called
vendor-counter
in the "vendor/demo" path set up in our provider.mkdir -p resources/views/vendor/demo/livewire \ && cp resources/views/livewire/counter.blade.php \ resources/views/vendor/demo/livewire/vendor-counter.blade.php
Attempt to use both in a view:
See error:
example repo: https://github.com/inmanturbo/volt-bug-report
The text was updated successfully, but these errors were encountered: