JsonTextArea

JsonTextArea は、JSON / JSON5 設定を編集するためのコンポーネントです。

基本的な使い方

Parsed value: {"enabled":true,"retry":3}
import React, { useState } from 'react';
import { JsonTextArea } from '@nocobase/client-v2';
import { Space, Typography } from 'antd';

export default function JsonTextAreaDemo() {
  const [value, setValue] = useState<unknown>({ enabled: true, retry: 3 });

  return (
    <Space direction="vertical" style={{ width: 420 }}>
      <JsonTextArea value={value} onChange={setValue} rows={6} json5 />
      <Typography.Text type="secondary">
        Parsed value: {JSON.stringify(value)}
      </Typography.Text>
    </Space>
  );
}

API

パラメータ説明
valueunknown現在の値
onChange(value: unknown) => void値変更時のコールバック
spacenumber文字列化するときのインデント
json5booleanJSON5 でパースするかどうか
showErrorbooleanパースエラーを表示するかどうか

関連リンク