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

fix: added ref support to button and touchable ripple component. #3992

Closed

Conversation

sangameshsomawar
Copy link
Contributor

Fixes: #3988

Summary

Added ref support for Button and TouchableRipple component.

Test plan

I tried creating ref for button and touchable ripples, it worked.

@callstack-bot
Copy link

callstack-bot commented Jul 22, 2023

Hey @sangameshsomawar, thank you for your pull request 🤗. The documentation from this branch can be viewed here.

@lukewalczak lukewalczak changed the title Added ref support to button and touchable ripple component. fix: added ref support to button and touchable ripple component. Jul 24, 2023
@lukewalczak lukewalczak added this to the 5.10.0 milestone Jul 25, 2023
@lukewalczak lukewalczak removed this from the 5.10.0 milestone Aug 2, 2023
@sangamesh1439
Copy link
Contributor

@lukewalczak Let me know if I can do something more to help reviewing/testing code?


type ButtonRef = React.ElementRef<typeof TouchableRipple>;

const Button: React.ForwardRefRenderFunction<ButtonRef, Props> = (
Copy link
Contributor

Choose a reason for hiding this comment

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

Have you tried something like this?

Suggested change
const Button: React.ForwardRefRenderFunction<ButtonRef, Props> = (
const Button = forwardRef({

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@DimitarNestorov I could not understand your point.

forwardRef is already added in the last line export default forwardRef(Button);

Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer if we do not explicitly set the type of Button.

Copy link
Contributor

Choose a reason for hiding this comment

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

@DimitarNestorov We cannot use forwardRef from src/utils/forwardRef.tsx because it does not support mentioning component level attribute, In our case TouchableRipple.supported = true; is a component level attribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants