Skip to content

Conversation

@capelski
Copy link

@capelski capelski commented Mar 9, 2021

Platforms affected

Google Chrome on Windows

What does this PR do?

Fix propTypes issues on browsers

What testing has been done on this change?

Launched the app in the Expo Client

@justinkchen
Copy link

thanks for this! would be great to get this bumped and merged in! thanks!

@FINKITT-PTY-LTD
Copy link

Yeah agreed, the merge would make my day guys!

@jaredswenson
Copy link

This works well, can we get a merge please?

@JijoBose
Copy link

Thanks, @capelski,
waiting for this to be merged 🚀

callbackOffsetMargin: PropTypes.number,
containerCustomStyle: ViewPropTypes ? ViewPropTypes.style : View.propTypes.style,
contentContainerCustomStyle: ViewPropTypes ? ViewPropTypes.style : View.propTypes.style,
containerCustomStyle: ViewPropTypes ? ViewPropTypes.style : View.propTypes ? View.propTypes.style : () => null,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

containerCustomStyle: ViewPropTypes ? ViewPropTypes.style : View.propTypes?.style ? View.propTypes.style : () => null

instead... Your's didnt work for me, but the ?. does....

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these solutions are awesome I'll try it out right away

containerCustomStyle: ViewPropTypes ? ViewPropTypes.style : View.propTypes.style,
contentContainerCustomStyle: ViewPropTypes ? ViewPropTypes.style : View.propTypes.style,
containerCustomStyle: ViewPropTypes ? ViewPropTypes.style : View.propTypes ? View.propTypes.style : () => null,
contentContainerCustomStyle: ViewPropTypes ? ViewPropTypes.style : View.propTypes ? View.propTypes.style : () => null,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above:

        contentContainerCustomStyle: ViewPropTypes ? ViewPropTypes.style : View.propTypes?.style ? View.propTypes.style : () => null,

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry - terrible at using this github stuff!!!

You change did not fix the problem, still got red errors in chrome.... The following (just in the Carousel.js) did fix it as a slight mod to yours:

containerCustomStyle: ViewPropTypes ? ViewPropTypes.style : View.propTypes?.style ? View.propTypes.style : () => null,
contentContainerCustomStyle: ViewPropTypes ? ViewPropTypes.style : View.propTypes?.style ? View.propTypes.style : () => null,

Copy link
Author

@capelski capelski Apr 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @cyphire. Which device and browser are you testing it from? The fix was working fine on a Windows 10 Chrome browser. The only difference in your code is checking that View.propTypes contains a property named style. In fact, your code would be more readable if you'd replace the ternary operator with an or operator:

Suggested change
contentContainerCustomStyle: ViewPropTypes ? ViewPropTypes.style : View.propTypes ? View.propTypes.style : () => null,
contentContainerCustomStyle: ViewPropTypes ? ViewPropTypes.style : View.propTypes?.style || () => null,

But again, in which case do you get a View.propTypes without the style property?

@BlameFelix
Copy link

This works, however I think the underlying problem is this. After applying the fix from the linked comment web also works fine for me.

@capelski
Copy link
Author

capelski commented May 2, 2021

As mentioned in #779 (comment), React Native deprecated propTypes. I'm closing this PR since it's not aligned with the React Native evolution and I'm creating #836, which removes ViewPropTypes usage instead of mocking it

@capelski capelski closed this May 2, 2021
@udemezue01
Copy link

How do we solve this, I am getting errors too

Copy link

@Chris-Imade Chris-Imade left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why isn't this correction merge...when I run yarn add react-native-snap-carousel I still get the not updated files

callbackOffsetMargin: PropTypes.number,
containerCustomStyle: ViewPropTypes ? ViewPropTypes.style : View.propTypes.style,
contentContainerCustomStyle: ViewPropTypes ? ViewPropTypes.style : View.propTypes.style,
containerCustomStyle: ViewPropTypes ? ViewPropTypes.style : View.propTypes ? View.propTypes.style : () => null,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these solutions are awesome I'll try it out right away

@steveberdy
Copy link

If you want this code in your project instead of the current, broken code, you can npm uninstall react-native-snap-carousel and then npm install git+https://github.com/capelski/react-native-snap-carousel or your own working fork. You don't have to wait for it to be in the official NPM registry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants