Your first screen
Build a note editor and show its text as you type.
Open the project from Installation. Replace src/App.tsx with this component. It renders a title, an editable native input, and a preview of the note.
import { useState } from 'react'
import { Text, TextInput, View, useSafeAreaInsets } from 'react-nitro-renderer'
export function App() {
const [note, setNote] = useState('')
const insets = useSafeAreaInsets()
return (
<View layout={{ flex: 1, paddingTop: insets.top + 24, paddingHorizontal: 20 }}>
<Text fontSize={28} fontWeight="bold">Field notes</Text>
<TextInput
placeholder="What did you notice?"
layout={{ marginTop: 16, padding: 12 }}
style={{ background: 0xf0f2edff, cornerRadius: 8 }}
onTextChanged={(change) => setNote(change.text)}
/>
<Text layout={{ marginTop: 24 }} fontWeight="semibold">Preview</Text>
<Text>{note}</Text>
</View>
)
}Run the app and type “First frost” in the field. The native input displays each edit and calls onTextChanged. Updating note renders the same words under Preview. The input owns its editing state, including the caret and keyboard composition. React state supplies the preview and lasts for the lifetime of this component.
Where the app starts
The starter already registers the named App export in src/index.tsx. Keep this entry when replacing the screen.
import { registerApp } from 'react-nitro-renderer'
import { App } from './App'
registerApp(App)registerApp installs the runtime through the renderer and mounts the component in the native window. Add more UI by composing components inside App. For a second screen with native back navigation, see Navigation.