-
Notifications
You must be signed in to change notification settings - Fork 103
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
Fixing Inertia SSR errors #74
Conversation
@@ -38,13 +39,16 @@ public function share(Request $request): array | |||
{ | |||
[$message, $author] = str(Inspiring::quotes()->random())->explode('-'); | |||
|
|||
return [ | |||
...parent::share($request), | |||
return array_merge(parent::share($request), [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this array_merge()
necessary? The React version doesn't use it, though either the spread or the merge will accomplish the same thing. Just wanted to double check so we can keep consistency between the React/Vue templates.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right you are, we could use the spread operator here. Thanks!
resources/js/ssr.tsx
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this file be ssr.ts
instead? There's no JSX being used, so probably not necessary to have that as the file type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I'll get that updated.
* Adding initial SSR fixes * fixing warning messages in SSR * Adding updates to ssr file to include global route var * Adding dev:ssr command * Adding light/dark mode fixes to support cookies and localstorage * updating the intertia return array * formatting * run formatter --------- Co-authored-by: Taylor Otwell <taylor@laravel.com>
This PR will fix the warnings and errors when running the starter kit using Inertia SSR.
Test this out by running:
You can also run:
Which is a new script that's added to the composer.json to run the SSR functionality.
You can also test this out by
disabling javascript
in the browser. If it's SSR, everything will work with Javascript Disabled; otherwise if you are running the defaultcomposer run dev
the pages will not render if you disable javascript; rightfully so.This PR has a similar PR on the react starter kit: laravel/react-starter-kit#53