owl
owl copied to clipboard
Cannot iterate over Set and Array props in Components
If I have a prop
that is of type Array
or Set
, I currently can't use their forEach
methods (or over iteration methods for that matter) in my Component
s, effectively making these Set
props
in particular unusable. This is due to props
being Proxy
s and
A discussion of this issue can be found at Stack Overflow.
duplicate of #420
@Zinston could you give me a short example to demonstrate this issue? I can't reproduce it
@ged-odoo One of the objects in my state (with useState
) is a Set
. In a Component
, I need to iterate over its values, which implies using forEach
on it. That doesn't work. If I don't use useState
it works fine.
For example, off the top of my hat: In a Component
state = useState({
mySet: new Set();
});
setToString(mySet: Set): string {
const items = [];
VNode[key].forEach(item => {
items.push(item);
});
return items.join('; ');
}
in XML:
<t t-esc="setToString(state.mySet)"/>
Error: Method Set.prototype.forEach called on incompatible receiver [object Object]
.
Same is true of Map.get
within XML. Similar error.