oblador / react-native-collapsible

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

Fixed the cannot read property 'style' of undefined issue for react-native-web > 0.12 #384

Closed kgrech closed 3 years ago

kgrech commented 3 years ago

The issue is caused by the change made in react-native-web 0.12.0:

Remove prop types exports from the package. These are deprecated in React Native and introduce significant DEV time performance cost. Flow types are now preferred (1ad1693)

More details here: PR#1537

I suggest the fix by adding extra || { style: () => {} } statement.

This way it still works with react-native-web, but it also would work with 0.12.0.

This way it compiles with a warning:

Attempted import error: 'ViewPropTypes' is not exported from 'react-native-web/dist/index' (imported as 'RNViewPropTypes') but it works.

We can of course just get rid of it ViewPropTypes, but then it might stop working with older versions of react-native-web, so maybe we can keep it with a warning for some time until most of the users update

adamhari commented 3 years ago

Can confirm that this resolves the issue for me on web