React Nitro

TextInput

Edit text with the platform keyboard.

App.tsx
<TextInput  multiline  defaultValue={initialNote}  onTextChanged={({ text }) =>    setNote(text)}/><Text>{note}</Text>
Field note
Preview

Meet at the bridge.

Edit the note. The preview below follows each text change.

Use defaultValue for the initial text. The field owns the current text and selection. Subscribe to onTextChanged to use the edited value elsewhere.

import { TextInput } from 'react-nitro-renderer'

export function NoteEditor({ onEdit }: { onEdit: (text: string) => void }) {
  return (
    <TextInput
      multiline
      placeholder="Write a note"
      onTextChanged={(change) => onEdit(change.text)}
    />
  )
}

Pass onBeforeTextChange to accept, reject, or transform an edit synchronously. A TextInputRef lets you call focus() or setText(). To switch between single-line and multiline editing, mount the field with a new React key. Text and input