Код: Выделить всё
`plugins: [
react(),
eslint(),
MonacoEditorPlugin({
languageWorkers: ['json'],
}),
],`
< /code>
Ниже приведен код React: < /p>
import MonacoEditor from 'react-monaco-editor';
export const CodeEditor = () => {
const jsonCode = `{
"employee": {
"name": "sonoo",
"salary": 56000,
"married": true
}
}`;
/**
* formatJSON
*/
function formatJSON(val: string) {
try {
const res = JSON.parse(val);
return JSON.stringify(res, null, 2);
} catch {
const errorJson = {
error: `非法返回${val}`,
};
return JSON.stringify(errorJson, null, 2);
}
}
return (
);
};
Подробнее здесь: https://stackoverflow.com/questions/794 ... ot-working