react-native-sg-basic-carousel 1.0.4 → 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 -3
  2. package/package.json +18 -17
package/index.tsx CHANGED
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable react-native/no-inline-styles */
2
- import { useState, useRef, useEffect, JSX } from "react";
2
+ import React, { useState, useRef, useEffect, JSX } from "react";
3
3
  import {
4
4
  View,
5
5
  FlatList,
@@ -7,6 +7,7 @@ import {
7
7
  StyleSheet,
8
8
  ViewStyle,
9
9
  StyleProp,
10
+ ImageBackground,
10
11
  } from "react-native";
11
12
 
12
13
  interface CarouselProps {
@@ -62,6 +63,10 @@ const BasicCarousel = ({
62
63
  },
63
64
  ).current;
64
65
 
66
+ if (!data || data.length === 0) {
67
+ return null;
68
+ }
69
+
65
70
  return (
66
71
  <View style={containerStyle}>
67
72
  <FlatList
@@ -102,9 +107,18 @@ const BasicCarousel = ({
102
107
 
103
108
  // Default Carousel Card: Used if no custom renderer is provided
104
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
+
105
115
  return (
106
116
  <View style={styles.defaultCard}>
107
- <View style={styles.imageBackground} />
117
+ <ImageBackground
118
+ source={{ uri: imageUri }}
119
+ style={styles.imageBackground}
120
+ resizeMode="cover"
121
+ />
108
122
  </View>
109
123
  );
110
124
  };
@@ -138,7 +152,6 @@ const styles = StyleSheet.create({
138
152
  borderRadius: 12,
139
153
  overflow: "hidden",
140
154
  height: "100%",
141
- backgroundColor: "red",
142
155
  },
143
156
  });
144
157
 
package/package.json CHANGED
@@ -1,31 +1,32 @@
1
1
  {
2
2
  "name": "react-native-sg-basic-carousel",
3
- "version": "1.0.4",
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": "^19.2.0",
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": {
28
27
  "react": "19.2.0",
29
- "react-native": "0.83.0"
28
+ "react-native": "0.83.0",
29
+ "@types/react": "^19.2.0",
30
+ "typescript": "^5.0.0"
30
31
  }
31
32
  }