react-native-sg-basic-carousel 1.0.2 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.tsx +16 -4
  2. package/package.json +19 -19
package/index.tsx CHANGED
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable react-native/no-inline-styles */
2
- import React, { useState, useRef, useEffect } from "react";
2
+ import React, { useState, useRef, useEffect, JSX } from "react";
3
3
  import {
4
4
  View,
5
5
  FlatList,
@@ -60,9 +60,13 @@ const BasicCarousel = ({
60
60
  if (viewableItems.length > 0) {
61
61
  setActiveIndex(viewableItems[0].index);
62
62
  }
63
- }
63
+ },
64
64
  ).current;
65
65
 
66
+ if (!data || data.length === 0) {
67
+ return null;
68
+ }
69
+
66
70
  return (
67
71
  <View style={containerStyle}>
68
72
  <FlatList
@@ -103,9 +107,18 @@ const BasicCarousel = ({
103
107
 
104
108
  // Default Carousel Card: Used if no custom renderer is provided
105
109
  const DefaultCarouselCard = ({ item }: { item: any }) => {
110
+ const imageUri =
111
+ typeof item === "object" && item?.image
112
+ ? item.image
113
+ : "https://www.sciencealert.com/images/2026/01/ai_psychosis_header-3.jpg";
114
+
106
115
  return (
107
116
  <View style={styles.defaultCard}>
108
- <View style={styles.imageBackground} />
117
+ <ImageBackground
118
+ source={{ uri: imageUri }}
119
+ style={styles.imageBackground}
120
+ resizeMode="cover"
121
+ />
109
122
  </View>
110
123
  );
111
124
  };
@@ -139,7 +152,6 @@ const styles = StyleSheet.create({
139
152
  borderRadius: 12,
140
153
  overflow: "hidden",
141
154
  height: "100%",
142
- backgroundColor: "red",
143
155
  },
144
156
  });
145
157
 
package/package.json CHANGED
@@ -1,32 +1,32 @@
1
1
  {
2
2
  "name": "react-native-sg-basic-carousel",
3
- "version": "1.0.2",
4
- "description": "An npm package to display basic carousel on react native applications",
3
+ "version": "1.0.5",
4
+ "description": "An npm package to display a basic carousel in React Native applications",
5
5
  "main": "index.tsx",
6
- "scripts": {
7
- "test": "npm run test"
8
- },
6
+ "license": "Apache-2.0",
7
+ "author": "Siddhant Goyal",
9
8
  "repository": {
10
9
  "type": "git",
11
10
  "url": "git+https://github.com/siddhant124/react-native-sg-basic-carousel.git"
12
11
  },
13
- "keywords": [
14
- "npm",
15
- "carousel",
16
- "mobile",
17
- "react",
18
- "native"
19
- ],
20
- "author": "Siddhant Goyal",
21
- "license": "Apache-2.0",
22
12
  "bugs": {
23
13
  "url": "https://github.com/siddhant124/react-native-sg-basic-carousel/issues"
24
14
  },
25
15
  "homepage": "https://github.com/siddhant124/react-native-sg-basic-carousel#readme",
26
- "dependencies": {
27
- "@types/react": "^18.3.11",
28
- "@types/react-native": "^0.72.8",
29
- "react": "^18.3.1",
30
- "react-native": "^0.75.4"
16
+ "keywords": [
17
+ "react-native",
18
+ "carousel",
19
+ "flatlist",
20
+ "mobile"
21
+ ],
22
+ "peerDependencies": {
23
+ "react": ">=17.0.0",
24
+ "react-native": ">=0.68.0"
25
+ },
26
+ "devDependencies": {
27
+ "react": "19.2.0",
28
+ "react-native": "0.83.0",
29
+ "@types/react": "^19.2.0",
30
+ "typescript": "^5.0.0"
31
31
  }
32
32
  }