Algolia for React Native: refine() method - react-native

I wish to use Algolia to setup InstantSearch in my React Native project. I am using this tutorial to learn the basics.
It appears in their RefinementList and InfiniteHits components there is a parameter: refine. This parameter seems to play a key role in the functionality of this tutorial's app.
Where can I get an example of how this refine() method would look like?
Please help me with some resources. An explanation of this refine() method would also help.
Thanks!

I think there's a typo in the documentation at the time of this writing (for which I opened a pull request), and the name of the actual prop is refineNext.
The documented InfiniteHits example from the React Native guide uses a connector, which is a lower-level abstraction allowing users to fully control the UI. This is what allows you to use React Native code for the UI while having access to the InfiniteHits data and logic. You can read more about the connectInfiniteHits connector in the documentation.
The provided refineNext function lets you load more results. It doesn't take any arguments, all you need to do is call it whenever you want to load more results from Algolia. In the example, it's being used in the onEndReached callback of React Native's FlatList component, whenever the hasMore provided prop is true. This allows loading more results once when the scroll position gets within onEndReachedThreshold of the rendered content.

Related

Problems with Kotlin react router dom element attribuute for binding a react component to URL

I'm currently working on a sample application to learn Kotlin/Js with the react library. When using the normal JSX syntax, a component can be set to be triggered when a specific URL hits using the BrowserRouter & Route API like below.
Main Component
Navigation Component as directed like in this youtube video
When attempting the above code in Kotlin, it resembles something like the screenshot below using the KotlinDSL
The main function where the component is rendered is shown below
However, that creates an Uncaught Error Exception like the one below
One of the reasons its also so difficult to debug is because my source maps dont work and hence most of my debugging errors are actually in Javascript. But anyways after searching up the javascript error, I found this article about the new Router update that disallows adding components as children.
As a result I tried to pass in the components through the element prop but there seems to be some incompatibility with them.
the element prop accepts an optional ReactNode? and I cant seem to convert my Function Component of type props to a ReactNode. When I try to pass in an optional ReactElement? by calling the create method, I also get an error.
I have been struggling with the Kotlin Documentation and can't seem to find enough examples of react-router implemented.
Can anyone help me out with how to pass in a Function COmponent into the element prop for the React Router?

Is there a way to enforce order of execution of props on a Native Component?

I came across a bug in a React Native app that makes use of a native view component, and tracked it down to the order of execution of the property settings methods (e.g. #ReactProp methods on Android).
I found that I had to put the prop method that needed setting first as the last prop in the component's JSX declaration, which is a little counter-intuitive.
Is there a way to enforce this order?
Although this doesn't specifically answer the question, one way around this, when specific props are dependent on each other like this, is to bundle them in an object, which on Android would be passed to the native method via a ReadableMap. That way all the dependent data is in one place and can be handled in the correct order.

Opinion on native base List component

I want to know that whether the <List> component being provided by native-base
styling library can be an alternative for <ListView> component.
I know that the the traditional listview by react-native is performance efficient
so is the List component of native base also performance efficient.
Check NativeBase Docs https://docs.nativebase.io/Components.html#list-def-headref
It says, List is deprecated
NativeBases List component is actually just a wrapper over React Native's ListView with some extra goodies included, so efficiency in terms of cell reuse, etc should be good.
See the source for List.

Algolia React Instantsearch - react native - 'query' search parameter not working

I'm using the react-instantsearch module on a React Native app. I'm using it as a controlled component, passing in a searchState like so:
<InstantSearch
appId='something'
apiKey='somethingElse'
indexName='index'
searchState={this.props.algoliaSearchState}
>
When I change the category (hierarchicalMenu) or location (aroundLatLng), this works fine, but when I change the query it has no effect on the hits that I get.
I can see that the query is being passed in (both by logging, and in react-native devtools:
Any ideas what could be going wrong here?
For a refinement to be applied, it needs to be present inside the search state and have a corresponding widget mounted.
For hierarchicalMenu it's HierarchicalMenu, for aroundLatLng it's Configure and for query it's SearchBox.
If you don't want any rendering for a widget just create a VirtualWidget. But for its refinement to be applied, it should be mounted.

'Global' modal in React Native

I'm building an app in React native, and basically, I need a modal(which will have the same content every time) to be available globally (in all components of app), so that I can be able to open it from anywhere in my app.
Obviously copy/pasting the same modal in all the components is not a good solution
Right now I'm having tons of trouble implementing it, so I would like to know what would be the best way to accomplish something like that
Use a Navigator and place your modal below it. Make it visible only when the state changes. The state can be changed from each component inside the Navigator via props.navigator.
You can see the full code with explanation here http://browniefed.com/blog/react-native-easy-overlay-modal-with-navigator/