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

Pass Forwarding Refs to the component #159

Closed
leonardoelias opened this issue Mar 18, 2020 · 1 comment
Closed

Pass Forwarding Refs to the component #159

leonardoelias opened this issue Mar 18, 2020 · 1 comment

Comments

@leonardoelias
Copy link

Today the components are like this:

function Button({
  isDisabled,
  isLoading,
  loadingText,
  isLink,
  children,
  ButtonWrapper,
  ...props
}) {
  // ... rest components

  return (
    <SelectedButton isLoading={isLoading} disabled={isDisabled} {...props}>
      {buttonInner}
    </SelectedButton>
  );
}

to

const Button = React.forwardRef(
  (
    {
      isDisabled,
      isLoading,
      loadingText,
      isLink,
      children,
      ButtonWrapper,
      ...props
    },
    ref
  ) => {
    // ... components

    return (
      <SelectedButton
        ref={ref}
        isLoading={isLoading}
        disabled={isDisabled}
        {...props}
      >
        {buttonInner}
      </SelectedButton>
    );
  }
);

So we can we want to forward the ref from the outside of.
https://reactjs.org/docs/forwarding-refs.html

I can work on that refctory and open a PR for better evaluation.

However, I would like to know how to trade.

@kylesuss
Copy link
Collaborator

Hi 👋 . Thanks for the suggestion. Can you describe the use case that you think the ref needs to be forwarded? So far we haven't needed that, but maybe I am missing something useful.

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

No branches or pull requests

3 participants