We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
onEdit
1 parent 5257366 commit 0dd8a93Copy full SHA for 0dd8a93
examples/basic/pages/index.tsx
@@ -1,5 +1,8 @@
1
import JsonViewer from '@textea/json-viewer'
2
import type React from 'react'
3
+import { useCallback, useState } from 'react'
4
+
5
+import type { InteractionProps } from '../../../src/type'
6
7
const example = {
8
string: 'this is a test string',
@@ -17,9 +20,13 @@ const example = {
17
20
}
18
21
19
22
const IndexPage: React.FC = () => {
23
+ const [src, setSrc] = useState<object>(() => example)
24
+ const handleEdit = useCallback((update: InteractionProps) => {
25
+ setSrc(update.updated_src)
26
+ }, [])
27
return (
28
<div>
- <JsonViewer src={example}/>
29
+ <JsonViewer src={src} onEdit={handleEdit}/>
30
</div>
31
)
32
0 commit comments