JsonEditor
JSON revisado mientras se escribe: dónde está el error, en palabras, y un botón que lo ordena.
import { JsonEditor } from '@sypnia/ui/react'
En esta página
Un evento de prueba
Código
import { useState } from 'react';
import { Field, JsonEditor } from '@sypnia/ui/react';
// The comma after «true» is a mistake: it says on which line. Remove it and press «Tidy up».
export default function Body() {
const [json, setJson] = useState('{"event": "order.paid",\n "notify": true,\n}');
return <Field label="Test event"><JsonEditor value={json} onChange={setJson} rows={6} /></Field>;
} Cuándo usarlo
Úsalo cuando
- Eventos de prueba, ajustes escritos en JSON.
No lo uses cuando
- Ajustes con forma conocida: dales sus propios campos.
Para todos
- Un error marca el campo como inválido y se dice con el número de línea.
Props
| JsonEditor | Tipo | Por defecto |
|---|---|---|
onChangeobligatorio | (v: string) => void | |
valueobligatorio | string | |
aria-describedby | string | |
aria-labelThe name for screen readers when there is no Field around it. | string | |
aria-labelledby | string | |
className | string | |
disabled | boolean | |
idInside a Field it comes from the Field. | string | |
invalidMarks the value as wrong. Inside a `<Field error>` it is set for you. | boolean | |
onRunRuns with Ctrl/⌘ + Enter. | (() => void) | |
placeholder | string | |
readOnly | boolean | |
rowsVisible lines before it scrolls. | number |