Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

react-native-runtime-stub.tsx

41 lines1020 Bytes

1import { createElement, type ReactNode } from 'react'
2​
3interface NativeViewProps {
4 children?: ReactNode
5 onChangeText?: (value: string) => void
6 onPress?: () => void
7 title?: string
8 value?: string
9}
10​
11function primitive(tag: string) {
12 return function Primitive({
13 children,
14 onChangeText,
15 ...props
16 }: NativeViewProps) {
17 return createElement(tag, {
18 ...props,
19 onChange: onChangeText
20 ? (event: { target: { value: string } }) =>
21 onChangeText(event.target.value)
22 : undefined,
23 children,
24 })
25 }
27​
28export const Button = ({ title, onPress }: NativeViewProps) =>
29 createElement('button', { onClick: onPress, children: title })
30​
31export const SafeAreaView = primitive('main')
32export const ScrollView = primitive('section')
33export const Text = primitive('span')
34export const TextInput = primitive('textarea')
35export const View = primitive('div')
36​
37export const StyleSheet = {
38 create<T extends Record<string, unknown>>(styles: T) {
39 return styles
40 },