-
-
Notifications
You must be signed in to change notification settings - Fork 12
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
how can i get all the parent keys until root when onSelect ? #27
Comments
@mengke111 Does your click event want to be on 'key' or 'value' ? |
import React from 'react';
import JsonView from '@uiw/react-json-view';
export default function Demo() {
return (
<JsonView
style={{
'--w-rjv-background-color': '#ffffff',
}}
value={{
name: 'John',
age: 30,
hobbies: ['reading', 'coding', 'swimming'],
address: {
street: '123 Main St',
city: 'New York',
country: {
name: 'Main ',
codex: '123'
}
}
}}
>
<JsonView.Row
as="div"
render={(props, { keyName, value, parentValue }) => {
return (
<div
{...props}
onClick={() => {
console.log("keyName", keyName)
console.log("value", value)
console.log("parentValue", parentValue)
}}
/>
)
}}
/>
</JsonView>
)
} |
I had the same question and I'm a bit confused about the answer. |
@andreimatei upgrade <JsonView.Row
as="div"
render={(props, { keyName, value, parentValue, keys = [] }) => {
return (
<div
{...props}
onClick={() => {
console.log("keys", keys)
}}
/>
)
}}
/> |
Thank you! I will try it. |
{
name: 'John',
age: 30,
hobbies: ['reading', 'coding', 'swimming'],
address: {
street: '123 Main St',
city: 'New York',
country: {
name: 'Main ',
codex: '123',
ss: 'fdfdf'
}
}
}
when i select codex ,I want get codex and country and address
function onSelect(e) {
console.log("onSelect")
console.log(e)
}
Thanks very much
The text was updated successfully, but these errors were encountered: