obipawan / react-native-hyperlink

A <Hyperlink /> component for react-native that makes urls, fuzzy links, emails etc clickable
MIT License
801 stars 76 forks source link

When used on Web, error about prop types appear. #58

Closed Njaah-0 closed 2 years ago

Njaah-0 commented 3 years ago

Describe the bug This error is given on Web: Failed prop type: Hyperlink: prop type linkStyle is invalid; it must be a function, usually from the prop-types package, but received undefined. in Hyperlink (created by _default)

This happens because Text.propTypes is no longer a thing in latest RNW.

To Reproduce Try using this package with latest RNW.

Expected behavior No error should be logged

Additional info I patched this in my own project by simply doing this: linkStyle: _propTypes["default"].oneOfType([_propTypes["default"].object, _propTypes["default"].number]),

brandonpearcy commented 3 years ago

I can confirm this patch works, but creates a new warning if you happen to use react-native-hyperlink on both web and native in the same project. I would suggest you remove the PropType for linkStyle altogether as a workaround.

  1. Edit node_modules/react-native-hyperlink/src/Hyperlink.js
  2. Remove the line with linkStyle: textPropTypes.style,
  3. Make your patch persistent somehow, e.g. npx patch-package react-native-hyperlink
obipawan commented 2 years ago

the latest version v0.0.22 has the fix with types.

duggster commented 2 years ago

Hi @obipawan do you know when v0.0.22 will be released?