Binary search in react native how to? - react-native

I need to ask user "Is your number higher than 50?"/ or 2 buttons with "Higher" ... "Lower".
So then i need to realize binary search.
I tried to make it in js with arrays, so it is works, but I can't do it in native.

Related

How to make a family tree app using React Native?

For school, I have to make my first app with React Native. It's a family tree app; my teacher said it's the best choice to make that with all View-elements, even the lines between family members. But I think that won't ever be possible to calculate all distances perfectly.
Isn't there any other way to make this kind of app?
I think you are right and you need to take something like https://github.com/software-mansion/react-native-svg
With SVG you can draw shapes and arrows to connect your tree items.
For React exists a beautiful library called https://reactflow.dev. Unfortunately, it is a Web-only solution, but you can check how they render trees and repeat it in RN.
Also, read this article about storing tree data in JS https://medium.com/#iampika/javascript-trees-b8f3b4261c3a it should be helpful.

React Native Multiple Images Picker

The problem
So, I am developing a react native application and I am facing the callenge of selecting multiple images from the user gallery. Just like apps like WhatsApp, Telegram, Twitter and even Reddit do. So with that in mind, i tried to use launchImageLibraryAsync from expo-image-picker but, as specified in their documentation, the "multiple selecion" of images is only supported on the web.
What I have thinked of
So, based on several searches, it seemed like i had to build my own "Gallery". To do this, so far i've tried to use #react-native-community/cameraroll and expo-media-library, but both of them requires that we pass the first property to the getPhotos (for #react-native-community/cameraroll) or to the getAssetsAsync (for expo-media-library) functions, which defines the first items to be fetched. This is a problem because I do not want to fetch like 20 items and then, when the user reaches the end of the list, it fetches more 20 items. I need something like this (this example is from Telegram). You can see that the app never stops me from scrolling, it goes all the way through my entire gallery.
What would also be nice
If you use reddit mobile, you can see that you can also select multiple photos using the several Apps like Google Photos, Files, Google Drive and so on.
This would be even nicer because I wouldn't need to implement a custom made Picker. Do you guys know how could I implement this?
OBS: I am using Expo with Bare Workflow, so I can use just about any package. I also opened a discussion at the Expo repo about it. You can check it here: https://github.com/expo/expo/discussions/15210.
Thank you in advance :)
I have been using this package called expo-images-picker check it out. It has similar function to what you need. It works in Mobile as well.
Link here

How to code a input mask for currency using TextInput in React Native (using Expo)

I have an app that makes extensive use of react-native-paper's TextInput. Many of these inputs have to deal with monetary units. I know that TextInput from react-native-paper provides a render prop that allows you to add a text input mask and many have already been written. However, I can't seem to find one that works with expo and I only want to eject if absolutely necessary (I like many of the conveniences that expo brings to the table).
Can anyone show me an example of how to use onChangeText to accomplish this on my own?
These are my requirements:
I want 2 decimal places
I want to prevent the user from entering more than 1 decimal (maybe it's better not to allow them to enter a decimal at all - I'll do it once they enter more than 2 digits)
Check out this sample
Of course you can use any regex

React native Flat list optimization

I am trying to build a contact list in react native. I don't do all the possible optimization that are mentioned in the following mentioned places.
React native flat list optimization
8 ways to optimize React native FlatList performance
how-to-optimize-your-react-native-flatlist
How did I optimize my React Native FlatList?
flatlist-performance-tips
react-native-optimized-flatlist
I have tried all these one by one. by flat list is too much smooth now. but the only problem is that it takes some time to load initially. I want it like the contact book how has no loading. her ei ma attaching video link how it is behaving.
my own flat list source code
Video
** anyone who can help me to resolve this. I am tired of this and now this becomes a headache for me. help will be really appreciated. ia m trying on this for one month but invain.**
Take a look at the docs specifically about the attributes maxToRenderPerBatch,updateCellsBatchingPeriod and removeClippedSubviews. In your case, it's rendering 50 items per batch of render, the updateCellsBatchingPeriod maybe is making the list update itself longer than expected and maybe if you set the prop removeClippedSubviews to true the list is going to stay fluid as you want.

showing mini graphs in listview react native

I need to show data in graphical representation like stock app in itunes.
There are many libs but I cant find one giving such functionalities.
Can Any body suggest how to implement.
Try using React-native-svg-charts
which you can control size and colors
here is an Example