react-shallow-testutils icon indicating copy to clipboard operation
react-shallow-testutils copied to clipboard

findWithProps?

Open jadamgreen1010-zz opened this issue 10 years ago • 3 comments

How would you feel about a 'findWithProp' interface? I like the convenience of the 'findWithClass' function. Is there any reason we couldn't do that with props not just classnames? I'd like to be able to use something like 'id' to select, too.

jadamgreen1010-zz avatar Sep 11 '15 23:09 jadamgreen1010-zz

Yeah, good idea. Were you thinking something like this:

const found = findWithProp(component, 'propName', propValue);

We'd need to think about what would happen with objects and arrays though. Would it be deep or just look at top-level props?

sheepsteak avatar Sep 13 '15 21:09 sheepsteak

You could use something like lodash's _.get and take a string that represents a deep query. Maybe even use lodash to make the call?

jadamgreen1010-zz avatar Sep 14 '15 17:09 jadamgreen1010-zz

+1, would love this functionality.

Rodeoclash avatar Dec 15 '15 05:12 Rodeoclash