You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+12-4Lines changed: 12 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,7 @@ Features include:
10
10
- fine-grained control over which elements can be edited, deleted, or added to
11
11
- customisable UI, through simple, pre-defined [themes](#themes), or specific CSS overrides
12
12
- self-contained — rendered with plain HTML/CSS, so no dependance on external UI libraries
13
+
- provide your own [custom component](#custom-nodes) to integrate specialised UI for certain data.
13
14
14
15
**[Explore the Demo](https://carlosnz.github.io/json-edit-react/)**
15
16
@@ -46,14 +47,21 @@ or
46
47
47
48
## Implementation
48
49
49
-
```js
50
+
```jsx
50
51
import { JsonEditor } from'json-edit-react'
51
52
52
53
// In your React components:
53
-
<JsonEditor data={ myDataObject } { ...props }>
54
-
54
+
<JsonEditor
55
+
data={ myData }
56
+
onUpdate={ ({newData} ) => {
57
+
// Set "myData" state, plus
58
+
// any desired side-effects.
59
+
}}
60
+
{ ...otherProps } />
55
61
```
56
62
63
+
You are responsible for maintaining the data state — in your `onUpdate` function, use the `newData` property to set `data`, which should update inside the editor.
64
+
57
65
## Usage
58
66
59
67
**(for end user)**
@@ -68,7 +76,7 @@ It's pretty self explanatory (click the "edit" icon to edit, etc.), but there ar
0 commit comments