I am building my first React Native app and I am trying to use hooks to store a large array of {}. When I try to append a {} that has a short .content it appends instantly to the array. However, when the .content is a long string it takes a while until it's added to the array. what can I do to improve that? I am using it for a chat app. Is using hooks to store the messages the right call or should I do something else?
The technique when things get too large is to break them down. You are going in the right direction.
Without seeing your code, I recommend you do one of these
useState
into multiple smaller onesuseState
that will only keep the chat message that
you show the useruseState
, the first one you will read only(don't add
anything to it often and depend on the reactiveness of react hook).
Another one only keeps the chat message that you will show to the
user. This one might need some kind of trial and error and logic to manage it beautifully.The point is only to keep what you really need for the user.