oblador / react-native-collapsible

Animated collapsible component for React Native, good for accordions, toggles etc
MIT License
2.43k stars 455 forks source link

Warning: Failed prop type: Collapsible: prop type `style` is invalid; it must be a function #392

Closed masaok closed 3 years ago

masaok commented 3 years ago

Hi! πŸ‘‹

Firstly, thanks for your work on this project! πŸ™‚

Today I used patch-package to patch react-native-collapsible@1.5.3 for the project I'm working on.

This is the warning I was getting:

Warning: Failed prop type: Collapsible: prop type style is invalid; it must be a function, usually from the prop-types package, but received undefined. at node_modules\react-native\Libraries\LogBox\LogBox.js:173:8 in registerError at node_modules\react-native\Libraries\LogBox\LogBox.js:59:8 in errorImpl at node_modules\react-native\Libraries\LogBox\LogBox.js:33:4 in console.error at node_modules\expo\build\environment\react-native-logs.fx.js:27:4 in error at node_modules\prop-types\checkPropTypes.js:20:6 in printWarning at node_modules\prop-types\checkPropTypes.js:82:22 in checkPropTypes at node_modules\react\cjs\react.development.js:1714:20 in validatePropTypes at node_modules\react\cjs\react.development.js:1813:21 in createElementWithValidation at src\screens\ChatScreen.tsx:156:14 in ChatScreen

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-collapsible/Collapsible.js b/node_modules/react-native-collapsible/Collapsible.js
index eae5a9f..f649c4d 100644
--- a/node_modules/react-native-collapsible/Collapsible.js
+++ b/node_modules/react-native-collapsible/Collapsible.js
@@ -1,7 +1,7 @@
 import React, { Component } from 'react';
 import PropTypes from 'prop-types';
 import { Animated, Easing } from 'react-native';
-import { ViewPropTypes } from './config';
+// import { ViewPropTypes } from './config';

 const ANIMATED_EASING_PREFIXES = ['easeInOut', 'easeOut', 'easeIn'];

@@ -13,7 +13,8 @@ export default class Collapsible extends Component {
     enablePointerEvents: PropTypes.bool,
     duration: PropTypes.number,
     easing: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
-    style: ViewPropTypes.style,
+    // style: PropTypes.style,
+    style: PropTypes.func,
     onAnimationEnd: PropTypes.func,
     children: PropTypes.node,
   };

This issue body was partially generated by patch-package.

Qcumbeer commented 3 years ago

I'm having the same issue

oblador commented 3 years ago

Fixed in 1.6.0