react-admin-json-view
react-admin-json-view copied to clipboard
Supported nested objects in field & input source with dotted notation
I have a nested object in my record, like this:
{
id: "abcdef",
info: {
tree: {
x: 1,
y: 2
}
}
}
Now if I use the JSON view components and put source="info.tree"
it doesn't work as the component looks for record[source]
. The React Admin native fields and inputs use lodash to resolve nested location:
import get from 'lodash/get';
...
const value = get(record, source);
Could you incorporate this into the field and input?
Just noticed that lodash/get was there before the RAv4 update release, so what was the reason for getting rid of lodash here?
commented in the MR
const record = useRecordContext(props);
is a pattern that is used in react admin codebase
it's more powerful, it would allow <FunctionField render={(rec) => <JsonField source="newfield" record={{newfield: rec.x.y.z}} />>
so this is a key missing piece because JsonField
doesn't support this (passing props to useRecordContext
@MrHertal ping