You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In follow up of inertiajs/inertia-laravel#109. I often need data that should only be sent only with the initial request. This would be useful for sending things you only need once, like an array with frontend translations or the theme configuration. It would be passed to the props of the component, regardless of whether it is the first request or sequential ones. The JS library would 'remember' the prop from the initial request.
It is similar to how Inertia::lazy works, but then something like Inertia::once. It probably makes most sense when used in middleware rather than on a page level. Here's an example, based on partial reloads.
// ALWAYS included on first visit
// NEVER included on partial reloads
// ONLY evaluated when needed
'translations' => Inertia::once(fn () => trans('frontend')),
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
In follow up of inertiajs/inertia-laravel#109. I often need data that should only be sent only with the initial request. This would be useful for sending things you only need once, like an array with frontend translations or the theme configuration. It would be passed to the props of the component, regardless of whether it is the first request or sequential ones. The JS library would 'remember' the prop from the initial request.
It is similar to how
Inertia::lazy
works, but then something likeInertia::once
. It probably makes most sense when used in middleware rather than on a page level. Here's an example, based on partial reloads.Any thoughts on this?
Beta Was this translation helpful? Give feedback.
All reactions