Skip to content

Lazy Evaluation Not Working as Expected #2237

Discussion options

You must be logged in to vote

That is expected. As per the documentation that you linked, wrapping the value in a Closure will only make it lazy-loaded on subsequent requests via Inertia when requested. First visit will always be evaluated and included with this method.

Whether you accept it as a prop or not does not matter as the props definition in the page only tells the page what props are available to be used. It does not mean the page will request only those props when loading the page.

In order to make sure that it's only evaluated when requested (meaning: completely lazy-loaded via a separate request), you need to wrap it in Inertia::lazy().

For reference, see the examples below: (Copy-pasted the documentation…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@joue-zero
Comment options

Answer selected by joue-zero
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants