chramos / react-native-skeleton-placeholder

SkeletonPlaceholder is a React Native library to easily create an amazing loading effect.
MIT License
674 stars 120 forks source link

Add children type to SkeletonPlaceholderItemProps to prevent warnings when nesting SkeletonPlaceholder.Item #99

Open shaunp-street opened 1 year ago

shaunp-street commented 1 year ago

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch react-native-skeleton-placeholder@5.2.3 for the project I'm working on.

When nesting SkeletonPlaceholder.Item typescript errors occur as there is not children prop.

image

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-skeleton-placeholder/lib/skeleton-placeholder.d.ts b/node_modules/react-native-skeleton-placeholder/lib/skeleton-placeholder.d.ts
index 58cfac7..7c8fc8d 100644
--- a/node_modules/react-native-skeleton-placeholder/lib/skeleton-placeholder.d.ts
+++ b/node_modules/react-native-skeleton-placeholder/lib/skeleton-placeholder.d.ts
@@ -33,6 +33,7 @@ declare type SkeletonPlaceholderProps = {
 };
 declare type SkeletonPlaceholderItemProps = ViewStyle & {
     style?: StyleProp<ViewStyle>;
+    children?: JSX.Element[] | JSX.Element;
 };
 declare const SkeletonPlaceholder: React.FC<SkeletonPlaceholderProps> & {
     Item: React.FC<SkeletonPlaceholderItemProps>;

This issue body was partially generated by patch-package.

sterlingwes commented 1 year ago

This was required for me (parent placeholder element can take multiple children)

diff --git a/node_modules/react-native-skeleton-placeholder/lib/skeleton-placeholder.d.ts b/node_modules/react-native-skeleton-placeholder/lib/skeleton-placeholder.d.ts
index 58cfac7..0fb7755 100644
--- a/node_modules/react-native-skeleton-placeholder/lib/skeleton-placeholder.d.ts
+++ b/node_modules/react-native-skeleton-placeholder/lib/skeleton-placeholder.d.ts
@@ -4,7 +4,7 @@ declare type SkeletonPlaceholderProps = {
     /**
      * Determines component's children.
      */
-    children: JSX.Element;
+    children: JSX.Element[] | JSX.Element;
     /**
      * Determines the color of placeholder.
      */
@@ -33,6 +33,7 @@ declare type SkeletonPlaceholderProps = {
 };
 declare type SkeletonPlaceholderItemProps = ViewStyle & {
     style?: StyleProp<ViewStyle>;
+    children?: JSX.Element[] | JSX.Element;
 };
 declare const SkeletonPlaceholder: React.FC<SkeletonPlaceholderProps> & {
     Item: React.FC<SkeletonPlaceholderItemProps>;
Splicer97 commented 1 year ago

Same for me. Can somebody create PR for this bug?

chramos commented 1 year ago

I appreciate if somebody create a PR

Splicer97 commented 1 year ago

I appreciate if somebody create a PR

https://github.com/chramos/react-native-skeleton-placeholder/pull/109