S
S
Sergey Saltanovich2020-09-03 17:28:27
JavaScript
Sergey Saltanovich, 2020-09-03 17:28:27

How to optimize TextInput/TextArea in React Native (+expo)?

Hello, it re-renders with every new character in the TextInput/TextArea, searched the web for optimization, found something related to removing the value attribute, etc. But it turned out to be pointless, because. rendering still happens.

How can you optimize to make input faster? Can a separate screen be created for it so that there are fewer elements?

return (
    <View style={styles.app}>
      <View>
        <TextInput 
          style={styles.input} 
          placeholder="Введите имя" 
          defaultValue={newPerson} 
          onChangeText={setNewPerson}/>
        <Button style={styles.buttonAdd} onPress={addPerson} title="Добавить"></Button>
      </View>
      <ScrollView style={styles.scroll}>
        {people.map(person => (
                <TouchableOpacity
                    onPress={() => navigation.navigate('User', person)} key={person.id}>
                    <View style={styles.person}>
                        <Text style={styles.personName}>{person.name}</Text>
                    </View>
                </TouchableOpacity>
            ))}
      </ScrollView>
    </View>
    )


PS Do not hit, better explain :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
davidnum95, 2020-09-04
@Sulti

Why didn't you post all the code?

re-renders with every new character in TextInput/TextArea

That's how it should work.
And it should not slow down with a small list, which means there is a problem in something else.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question