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

ForwardRef support - SwitchField #860

Merged
merged 2 commits into from
Nov 24, 2021
Merged

ForwardRef support - SwitchField #860

merged 2 commits into from
Nov 24, 2021

Conversation

reesscot
Copy link
Contributor

Description of changes:
This PR adds forward ref support for the SwitchField primitive by wrapping it in React.forwardRef.

const CustomerComponent = () => {
  const ref = React.useRef(null); // ref.current.nodeName will be `DIV`
  
  return (
    <SwitchField ref={ref}  />
  );
};

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@changeset-bot
Copy link

changeset-bot bot commented Nov 23, 2021

🦋 Changeset detected

Latest commit: 7cc923e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@aws-amplify/ui-react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

@hvergara hvergara left a comment

Choose a reason for hiding this comment

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

LGTM 🎉

describe('Switch wrapper', () => {
it('should pass through the className', async () => {
const { container } = render(
<SwitchField label={label} className={'my-switch'} />
<SwitchField label={label} className="my-switch" />
Copy link
Contributor

Choose a reason for hiding this comment

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

thanks!

@reesscot reesscot temporarily deployed to ci November 23, 2021 22:12 Inactive
@reesscot reesscot temporarily deployed to ci November 23, 2021 22:12 Inactive
@reesscot reesscot temporarily deployed to ci November 23, 2021 22:12 Inactive
@reesscot reesscot temporarily deployed to ci November 23, 2021 22:31 Inactive
Copy link
Contributor

@zchenwei zchenwei left a comment

Choose a reason for hiding this comment

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

Looks great!

@reesscot reesscot merged commit b0985f6 into main Nov 24, 2021
@reesscot reesscot deleted the forward-ref-switchfield branch November 24, 2021 17:44
@github-actions github-actions bot mentioned this pull request Nov 24, 2021
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.

3 participants