component.prop("id") returned with component.find("#foo")
See original GitHub issueIs this a bug report?
Yes
Environment
enzyme@3.0.0
Steps to Reproduce
When a component is mounted with JSDOM the selector library does not differentiate props.id and element.id
using react router as an example
const test = mount(<Link id="foo" />)
const fooLink = test.find("#foo) <-- returns 2 nodes (<Link /> + <a>)
Expected Behavior
I would not expect a custom component with the prop id to be returned when querying with a CSS selector.
test.findWhere(n => n.prop("id") === foo)
<-- expect to return 2 nodestest.find("#foo")
<-- expect to return a single node
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (9 by maintainers)
Top Results From Across the Web
component.prop("id") returned with component.find("#foo")
I would not expect a custom component with the prop id to be returned when querying with a CSS selector. test.findWhere(n => n.prop("id")...
Read more >How to get "key" prop from React element (on change)?
You will need to pass value in key as a different prop. From docs: Keys serve as a hint to React but they...
Read more >Props | Vue.js
When objects and arrays are passed as props, while the child component cannot mutate the prop binding, it will be able to mutate...
Read more >React — Dynamic Component Names with JSX - Medium
Attempting to set the tag name (directly) via a general expression. This wont work and will cause a compiler error. render() { return...
Read more >Passing Functions to Components - React
There are several ways to make sure functions have access to component attributes like this.props and this.state , depending on which syntax and...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I have opened #1907 for the problems which occur regardless of this issue.
Perhaps all that needs to be done is for there to be a convenience API, something like
findHost
which was a shortcut forhostNodes().find()
At least having such a thing be present in documentation would give it more visibility and allow the find documentation to call out the circumstance in which using it would be appropriate.