Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle text input in react native generator #1435

Merged
merged 10 commits into from
May 17, 2024
4 changes: 3 additions & 1 deletion packages/core/src/generators/react-native/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,15 @@ const PROCESS_REACT_NATIVE_PLUGIN: Plugin = () => ({
if (node.bindings.onClick) {
node.name = 'Pressable';
}
if(node.bindings.onChange){
node.name = 'TextInput'
}
samijaber marked this conversation as resolved.
Show resolved Hide resolved
} else if (
node.properties._text?.trim().length ||
node.bindings._text?.code?.trim()?.length
) {
node.name = 'Text';
}

if (node.properties.class) {
delete node.properties.class;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/generators/react/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ const getDefaultImport = (json: MitosisComponent, options: ToReactOptions): stri
if (type === 'native') {
return `
import * as React from 'react';
import { FlatList, ScrollView, View, StyleSheet, Image, Text, Pressable } from 'react-native';
import { FlatList, ScrollView, View, StyleSheet, Image, Text, Pressable, TextInput } from 'react-native';
`;
}
if (type === 'taro') {
Expand Down