Closed ryssbowh closed 2 years ago
In the Neo eager loading docs, the use of block.useMemoized(entry.neoField)
assumes that the content of entry.neoField
has been eager loaded and is an array of Neo blocks, rather than an actual Neo field instance.
Using useMemoized()
without an argument tells the block to use a memoized dataset, without actually giving it a dataset to use, which means it's assumed that a memoized dataset has already been set. If it hasn't already been set, you'd need to call block.setAllElements(blocks)
separately to set it. That isn't mentioned in the docs and I'll make a note to clarify it.
In your case, it looks like changing the line
{% do neoBlock.useMemoized() %}
to
{% do neoBlock.useMemoized(value) %}
should resolve the issue.
Description
It's not quite clear what
benf\neo\elements::useMemoized
first argument should be :In v2 the doc says we have to pass the Neo field but the method's typing (from comments) is
bool|array
so I guess that was the same than passingtrue
, which seemed to work.In v3 passing the neo field doesn't work anymore, the typing has actively changed to
bool|array
. And passingtrue
results in this error :I use this method in a twig template :
My Neo field
neo
has one blocktest
with one fieldassets
and is eager loaded previously with the following :["neo","neo.test:assets"]
Steps to reproduce
useMemoized
without argument on a neo blockOther information