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(react): Conditionally render deprecation warning #3269

Merged
merged 6 commits into from
Jan 6, 2023

Conversation

joebuono
Copy link
Contributor

@joebuono joebuono commented Jan 5, 2023

Description of changes

Only show the Link component's to prop deprecation warning if the customer does NOT provide an as prop.

Fixes: #2889

Issue #, if available

#2889

Description of how you validated changes

Tested locally with a few examples on the docs site.

Checklist

  • PR description included
  • yarn test passes
  • Tests are updated

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@joebuono joebuono requested a review from a team as a code owner January 5, 2023 21:29
@changeset-bot
Copy link

changeset-bot bot commented Jan 5, 2023

🦋 Changeset detected

Latest commit: 942252d

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

@joebuono joebuono temporarily deployed to ci January 5, 2023 21:52 — with GitHub Actions Inactive
@joebuono joebuono temporarily deployed to ci January 5, 2023 21:52 — with GitHub Actions Inactive
@joebuono joebuono temporarily deployed to ci January 5, 2023 21:52 — with GitHub Actions Inactive
@joebuono joebuono temporarily deployed to ci January 5, 2023 21:52 — with GitHub Actions Inactive
dbanksdesign
dbanksdesign previously approved these changes Jan 5, 2023
Copy link
Contributor

@dbanksdesign dbanksdesign left a comment

Choose a reason for hiding this comment

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

One non-blocking comment, LGTM!

message:
"The Link component's to prop will soon be deprecated. " +
'Please see the Amplify UI documentation for using the Link component with routing libraries: ' +
'https://ui.docs.amplify.aws/react/components/link#routing-libraries',
});
return (
<View
as={as}
as={as ?? 'a'}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we use a ternary here to be more explicit?

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

it('should not call console.warn if "to" prop is used with "as" prop', async () => {
const spyWarn = jest.spyOn(console, 'warn');
render(<SampleRoutingApp />);
expect(spyWarn).not.toHaveBeenCalled();
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

Joe Buono added 2 commits January 5, 2023 16:55
@joebuono joebuono temporarily deployed to ci January 5, 2023 23:15 — with GitHub Actions Inactive
@joebuono joebuono temporarily deployed to ci January 5, 2023 23:15 — with GitHub Actions Inactive
@joebuono joebuono temporarily deployed to ci January 5, 2023 23:15 — with GitHub Actions Inactive
@joebuono joebuono temporarily deployed to ci January 5, 2023 23:35 — with GitHub Actions Inactive
@joebuono joebuono temporarily deployed to ci January 5, 2023 23:35 — with GitHub Actions Inactive
@joebuono joebuono temporarily deployed to ci January 5, 2023 23:35 — with GitHub Actions Inactive
@joebuono joebuono temporarily deployed to ci January 5, 2023 23:35 — with GitHub Actions Inactive
Copy link
Contributor

@dbanksdesign dbanksdesign left a comment

Choose a reason for hiding this comment

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

LGTM!

@joebuono joebuono merged commit 09b4832 into main Jan 6, 2023
@joebuono joebuono deleted the conditional-deprecation-warning branch January 6, 2023 19:22
@github-actions github-actions bot mentioned this pull request Jan 6, 2023
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.

Use Link component with React Router Dom v6.x
3 participants