Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native > Support Text as component #6451

Closed
wants to merge 2 commits into from
Closed

Conversation

lucarge
Copy link

@lucarge lucarge commented Nov 2, 2018

Hi all,
since six months the react-native implementation of Text implemented forwardRef. This means that, while a Text component is legit as a Link (it implements the onPress prop), it's not a function anymore. Instead, it will be an object with a render function.

Unfortunately, the right prop type for forwardRef does not exists yet.

This PR allows Text to be passed as component to Link, without prop-types warnings and maintaining a good level of safety checks.

I hope you'll be ok with merging this, and thanks again for react-router 🙌

Hi all,
[since six months](facebook/react-native@e708010) the `react-native` implementation of `Text` implemented `forwardRef`. This means that, while a `Text` component is legit as a `Link` (it implements the `onPress` prop), it's not a function anymore. Instead, it will be an object with a render function.

Unfortunately, the right prop type for `forwardRef` [does not exists yet](facebook/prop-types#200).

This PR allows `Text` to be passed as `component` to `Link`, without `prop-types` warnings and maintaining a good level of safety checks.

I hope you'll be ok with merging this, and thanks again for `react-router` 🙌
Copy link
Member

@mjackson mjackson left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, @lucarge :)

Add a reminder to replace the shape with the right prop-type when it'll be available.
@frehner
Copy link
Contributor

frehner commented Dec 12, 2018

Alternatively, you could go down the route that we did for Route and use react-is so you don't have to wait for prop-types to be updated :)

https://github.com/ReactTraining/react-router/blob/9d278b4b110f38479725fe5a1104990c2f3e76c2/packages/react-router/modules/Route.js#L82

@stale
Copy link

stale bot commented Sep 10, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Sep 10, 2019
@stale stale bot closed this Sep 17, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Nov 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants