You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This will scaffold a new React Native project with TypeScript support using Expo.
143
143
144
+
Once your project scaffolding is ready, navigate to the project directory and install the required dependencies:
145
+
146
+
```shell
147
+
cd typesense-react-native-search-bar
148
+
npm install
149
+
npm i react-instantsearch-core typesense-instantsearch-adapter
150
+
```
151
+
152
+
Let's go over the key dependencies:
153
+
154
+
-**react-instantsearch-core** - Provides InstantSearch hooks and components for React Native
155
+
-**typesense-instantsearch-adapter** - Connects InstantSearch with Typesense
156
+
144
157
:::tip Note
145
-
Unlike web frameworks, React Native doesn't use the Typesense JavaScript client or InstantSearch.js directly. Instead, we'll make direct API calls to Typesense using the Fetch API, which is more suitable for mobile applications.
158
+
React Native can use `react-instantsearch-core` with the `typesense-instantsearch-adapter`, just like web frameworks. This gives you access to powerful InstantSearch hooks and widgets. Alternatively, you can make direct API calls to Typesense using the Fetch APIfor a lighter implementation.
146
159
:::
147
160
148
161
## Project Structure
@@ -233,10 +246,8 @@ Let's create the project structure step by step. After each step, we'll show you
233
246
authors:string[];
234
247
image_url:string;
235
248
publication_year:number;
236
-
}
237
-
238
-
exportinterfaceDocument {
239
-
document:Book;
249
+
average_rating?:number;
250
+
ratings_count?:number;
240
251
}
241
252
```
242
253
@@ -265,31 +276,28 @@ Let's create the project structure step by step. After each step, we'll show you
This utility function makes a direct HTTP request to the Typesense server. Unlike web frameworks that use InstantSearch.js, React Native apps typically use the Fetch API for better performance and smaller bundle sizes on mobile devices. However, this also means that if you want advanced features like debouncing, you'll need to implement them manually.
300
+
This utility file creates the Typesense InstantSearch adapter, which bridges Typesense with InstantSearch. The adapter handles all the communication with Typesense and provides a search client that works seamlessly with `react-instantsearch-core` hooks.
293
301
294
302
6. Create the component files:
295
303
@@ -324,25 +332,18 @@ Let's create the project structure step by step. After each step, we'll show you
@@ -361,7 +362,7 @@ Let's create the project structure step by step. After each step, we'll show you
361
362
});
362
363
```
363
364
364
-
The `TextInput` component is React Native's equivalent of an HTML input field. The `onChangeText` prop automatically handles text changes, making it simpler than web's `onChange` event.
365
+
This component uses the `useSearchBox` hook from `react-instantsearch-core` to connect the search input to Typesense. The `query` value and `refine` function are provided by InstantSearch, which handles debouncing and search state management automatically.
365
366
366
367
8. Create the `BookCard` component in `components/BookCard.tsx`:
367
368
@@ -434,69 +435,50 @@ Let's create the project structure step by step. After each step, we'll show you
0 commit comments