Skip to content

Commit 5aaa83f

Browse files
committed
Small tweak
1 parent 01ea898 commit 5aaa83f

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

README.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -252,14 +252,16 @@ Since there is very little user feedback when clicking "Copy", a good idea would
252252

253253
In addition to the "Copy", "Edit" and "Delete" buttons that appear by each value, you can add your own buttons if you need to allow some custom operations on the data. Provide an array of button definitions in the `customButtons` prop, in the following definition structure:
254254

255-
```js
255+
```ts
256256
{
257-
Element: React.FC,
258-
onClick: (nodeData: NodeData, e: React.MouseEvent) => void
257+
Element: React.FC<{ nodeData: NodeData }>,
258+
onClick?: (nodeData: NodeData, e: React.MouseEvent) => void
259259
}
260260
```
261261
Where `NodeData` is the same data structure received by the previous "Update Functions".
262262

263+
The `onClick` is optional -- don't provide it if you have your own `onClick` handler within your button component.
264+
263265
## Filter functions
264266

265267
You can control which nodes of the data structure can be edited, deleted, or added to, or have their data type changed, by passing Filter functions. These will be called on each property in the data and the attribute will be enforced depending on whether the function returns `true` or `false` (`true` means *cannot* be edited).

src/ButtonPanels.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export const EditButtons: React.FC<EditButtonProps> = ({
126126
</div>
127127
)}
128128
{customButtons?.map(({ Element, onClick }, i) => (
129-
<div key={i} onClick={(e) => onClick && onClick(nodeData, e)}}>
129+
<div key={i} onClick={(e) => onClick && onClick(nodeData, e)}>
130130
<Element nodeData={nodeData} />
131131
</div>
132132
))}

0 commit comments

Comments
 (0)