-
Notifications
You must be signed in to change notification settings - Fork 277
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
[JSS][NextJS] - fix: Prevent passing internalLinkMatcher prop #847
Conversation
@bhgeorge is attempting to deploy a commit to the Sitecore JSS Team on Vercel. A member of the Team first needs to authorize it. |
Hello @bhgeorge. This seems good to me. Can you please change the target branch to |
…t Link component.
@CobyPear Rebased and changed target. Thanks! |
@bhgeorge please check the following lint error:
You can run Thinking about this a bit more, I wonder if another solution to this could be removing the link matcher from the props instead of changing the shape of the returned props, just to keep it easier to maintain in the future. Any thoughts @Sitecore/jss-dev-reviewers ? |
Agree, removing the |
I will go ahead and change the implementation and add a unit test. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me. Thanks @bhgeorge for the contribution!
@@ -3,7 +3,7 @@ import { NextRouter } from 'next/router'; | |||
import NextLink from 'next/link'; | |||
import { Link as ReactLink } from '@sitecore-jss/sitecore-jss-react'; | |||
import { use, expect, spy } from 'chai'; | |||
import { mount } from 'enzyme'; | |||
import { mount, render } from 'enzyme'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like unused 'render' import snuck in?
Prevented passing
internalLinkMatcher
prop to React Link component as it is an invalid HTML element prop.Description / Motivation
While attempting to use a custom link matcher (
/^\/|^\#/g
) to allow internal anchor links, an error occurred for all non-internal link values used in the same component.When a non-internal link is detected, it attempts to pass all props, including the unused
internalLinkMatcher
to the JSS React Link component, which then attempts to print it onto the anchor link, resulting in the following error:We can prevent this error by simply not passing the prop to the JSS React Link component.
Testing Details
Tested by utilizing forked version of JSS in existing project.
Types of changes
/docs
directory)