Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native text input is very slow to update

I have a chat app for iOS and Android - basic layout with a list of messages and an input field to type and send a message. After a few dozen messages come in typing gets very slow. The list scrolling still works smoothly though.

I checked with the iOS memory tools and it reports that I don't have a memory leak. On Android systrace, it shows that deliverInputEvent takes over 300ms.

How to I figure out what makes deliverInputEvent take so long?

Android Systrace

like image 217
Allen Avatar asked May 15 '18 01:05

Allen


People also ask

How do you get suggestions while typing in text input in react native?

Just show a view beneath the TextInput that will contain a list of matching words with the input text, and you can control that views visibility when user selects a word from the list. Dont forget to make it absolute.

How do you fix the issue where we can't type in a React input text field?

To solve the issue of being unable to type in an input field in React, make sure to use the defaultValue prop instead of value for uncontrolled input fields. Alternatively, set an onChange prop on the field and handle the change event.

Why is react native slow on Android?

Launch time. Slow app launch is another issue of React Native apps. If your app opens too slowly, you probably have too many dependencies in your app and you're using slow components. Try to use fast, high-performance components and decrease the number of dependencies in your app.

How do I set the length of input text in react native?

Use the maxLength prop to set a character limit on an input field in React, e.g. <input maxLength={5} /> . The maxLength attribute defines the maximum number of characters the user can enter into an input field or a textarea element.


2 Answers

Seems like a bug in React Native: https://github.com/facebook/react-native/issues/19126

like image 94
Hopia Avatar answered Sep 21 '22 11:09

Hopia


I have the same app and the same problem. In my case, the TextInput becomes slow when starting typing. I noticed that autocorrect takes some time to suggest words on the keyboard and so I turned it off. Now it works better. I know it's not the best solution, but ... ¯ \ _ (ツ) _ / ¯

autoCorrect={false}
like image 43
David Jesus Avatar answered Sep 20 '22 11:09

David Jesus