-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JsonField can't resolve dot notation for source parameter #4
Comments
Hi @fbigand thanks for reporting this bug. It should be fixed in this new release: https://github.com/MrHertal/react-admin-json-view/releases/tag/v1.0.4 |
Thank you for your response! I used this object for the test:
And I called JsonField like this inside my Show view:
Both of them render an empty json. |
Thanks for your response. It would be interesting to know what your import { FunctionField } from 'react-admin';
<FunctionField
label="Test"
render={(record) => {
console.log(record);
return <JsonField source="content" record={record} />;
}}
/> I would like to know if your content field is a string like this:
Or if it is an already parsed nested object like this: content:
test_array: Array(4)
0: 1
1: 2
2: 3
3: 4
length: 4
__proto__: Array(0)
test_object:
test: "test"
__proto__: Object
__proto__: Object |
The console.log displays the record that wraps the "content" attribute, and it is displayed as Javascript object.
|
This is weird, I could not reproduce. Here is what I tried: import { SimpleShowLayout, FunctionField } from "react-admin-json-view";
import { JsonField } from "react-admin-json-view";
<SimpleShowLayout>
<FunctionField
label="content.test_array"
render={(record) => {
const flowParams = JSON.parse(record.flowParams);
console.log(flowParams);
return (
<JsonField
source="content.test_array"
record={{ ...record, content: flowParams }}
/>
);
}}
/>
<FunctionField
label="content.test_object"
render={(record) => {
const flowParams = JSON.parse(record.flowParams);
console.log(flowParams);
return (
<JsonField
source="content.test_object"
record={{ ...record, content: flowParams }}
/>
);
}}
/>
</SimpleShowLayout> On my project,
{test_array: Array(4), test_object: {…}}
test_array: (4) [1, 2, 3, 4]
test_object: {test: "test"}
__proto__: Object As a result, I got this: Can you check the difference with your code? Did you restart your project after upgrading this package? (sorry I have to make sure 🙂) |
Thank you for your last remark, because it is most probably that the package was not updated inside the docker container that is running the application. |
What did you want to do
I wanted to pass a dot notation string to JsonField component
<JsonField source="source.nested" />
What did you expect
I expected to have my nested component displayed correctly
What happened instead
It displays
"root":{}
I don't know if this a bug, a upcoming feature or a wanted behavior, but the strange thing is that I have no problem with the JsonInput component using dot notation.
The text was updated successfully, but these errors were encountered: