this in __functionProps
Morcatko opened this issue · 0 comments
First thanks for this library. It solves exactly the problem I have (configuring UI and storing the setting into DB)
I tried to use __functionProps
and the this
is something different then I would expect. I have jsonx like this:
{
"component": "Fragment",
"children": [
{
"component": "MyComponent",
"resourceprops": { ... },
"__functionProps": {
"function": "func:this.functions.getValue"
}
},
....
]
}
my resourceObject
:
{
"someValues": {...},
"functions": {
"getValue": () => "getValue result"
}
}
and I call
jsonx.getReactElement(jsonx, resourceObject);
When I call getValue
function in MyComponent
I get undefined result. Actually it is calling empty function generated here: https://github.com/repetere/jsonx/blob/master/src/props.js#L388
After some debugging I noticed that this
in getFunctionFromProps
is part of jsonx (the MyComponent
child) and not the resourceObject
.
What is the use case for calling function on props (this), that you will get in a component and you can call it there?
Is this intentional or a bug?
Am I doing something wrong?
Is it possible to call a function on resourceObject
?
Thank you.