inertia-laravel
inertia-laravel copied to clipboard
Ability to add class to @inertia directive
This implements #370
@reinink is there something about this PR that is incorrect?
Hey! So I really like this PR, but the only issue is it's broken when running Inertia in SSR, since we recreate the wrapper div#app element in SSR:
Vue 3: https://github.com/inertiajs/inertia/blob/master/packages/inertia-vue3/src/createInertiaApp.js#L30-L36 React: https://github.com/inertiajs/inertia/blob/master/packages/inertia-react/src/createInertiaApp.js#L28-L33
If we're going to do this, we'll need to find a way to make that work first.
Ahh I see, what about this approach?
https://github.com/nurdism/inertia-laravel/blob/issue-370/src/Directive.php https://github.com/nurdism/inertia/blob/issue-370-patch-1/packages/inertia-vue3/src/createInertiaApp.js
I'm not very familiar with react ssr, not sure how to pass the classes string to the createElement function.
I just realized this doesn't work if you use the compileHead function, but maybe this could be added to the inertia config and do the same thing.
I've added a config option 'app' that allows you to pass 'classes' string from it, the @inertia directive should function normally w/o any added prams, it defaults to input, then config and then the standard 'app' and reads the classes string directly from the config.
With the ssr request it modifies the $page and adds 'classes' to the request, it pulls the classes string from the config. That can then be picked up and passed the createElement or h function.
Let me know if you have any questions or concerns
@reinink is this PR ever getting merged or is this something I should just add to my project manually instead?