React Native MantineInputs

JsonInput

Textarea with JSON validation and formatting

Import: import { JsonInput } from 'react-native-mantine';

Usage

import { JsonInput } from 'react-native-mantine';

<JsonInput
  label="Package config"
  placeholder='{"key": "value"}'
  validationError="Invalid JSON"
  formatOnBlur
  minRows={4}
  value={value}
  onChangeText={setValue}
/>

Props

PropTypeDefaultDescription
valuestringValue for controlled component
defaultValuestringDefault value for uncontrolled component
onChangeText(value: string) => voidCalled when value changes
validationErrorReact.ReactNode"Invalid JSON"Error message displayed when the value cannot be parsed
formatOnBlurbooleanfalseDetermines whether valid JSON should be pretty-printed on blur
serializetypeof JSON.stringifyJSON.stringifyFunction to serialize value into a string
deserializetypeof JSON.parseJSON.parseFunction to deserialize string value
labelReact.ReactNodeInput label, inherited from Textarea
descriptionReact.ReactNodeInput description, inherited from Textarea
errorReact.ReactNodeError message, takes precedence over validationError
minRowsnumber3Minimum number of visible text lines, inherited from Textarea
maxRowsnumberMaximum number of visible text lines, inherited from Textarea
autosizebooleanfalseAuto-grow textarea to fit content, inherited from Textarea

Source on GitHub · npm