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
Unknown prop active
on <a> tag when nesting Pager.Item inside a LinkContainer
#2304
Comments
No, this is react-bootstrap/react-router-bootstrap#185 |
Wow, we've just created a circular link chain from one issue back to this one! Could you elaborate though? Here is my workaround:
It creates a component 'FixedPagerItem', which acts like Pager.Item, works as expected, and does not produce the warning. I believe react-router-bootstrap's LinkContainer passes 'active' to you in case you want to do something with it to render depending on whether this route is already active, but you can't pass it onto the children. That said, if you believe I'm misusing <LinkContainer>, please suggest an alternative. The use case I have is that I wanted to render an actual <a href="..."> link users can open in a new tab or bookmark. Is this possible with Pager.Item? Side note: the documentation says that "Pager.Item" has no public props, which suggests this is achieved by wrapping it (somehow). |
the problem is that LinkContainer is for components that expect and active prop, not just any component that is a link. Pager.Item should pass through its props to the link tag because otherwise you'd have to whitefish all possible Dom properties for anchors. as @taion is noting the fix, if feasible, is to keep LinkContainer from passing active for page items. |
In this issue, taion himself comments: "I think you're misunderstanding what that warning means, and what the point of <LinkContainer> is. <LinkContainer> is exactly intended to inject down onClick, href, and active props. It's the responsibility of the contained component (as is the case with React-Bootstrap components) to strip out the active prop and render the relevant active state." Does this not mean that it's the responsibility of 'Pager.Item' (which is the contained component) to strip out the active property? You're saying it should only strip it out if the child of LinkContainer is a Pager.Item? Wouldn't that violate the idea that components can be implemented independently of what a user chooses to apply them to? I would tend to believe that the solution would indeed be for Pager.Item to "whitefish" only allowable properties to the SafeAnchor/link tag - this, at least, seems to be the intent of why React.js introduced this warning in the first place (?) Please explain more. |
Also, if I'm using <LinkContainer> wrongly, could you suggest an alternative component that preserves the same user experience? |
Please see my comments on react-bootstrap/react-router-bootstrap#185. |
Thanks. I interpret this as saying that <LinkContainer> is the correct component to use for my use case, but will need to be fixed in the future. Till then I'll use my workaround. |
@godmar your fix was helpful. thanks ;) |
I'm nesting a Pager.Item inside a react-router-bootstrap LinkContainer, which passes on an 'active' property. As a result, I'm getting:
According to this issue this is a problem in Pager.Item, not LinkContainer. It should not pass all props to its descendants.
The text was updated successfully, but these errors were encountered: