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

Select component based on matching criteria function #195

Open
ChrisLane opened this issue Apr 26, 2023 · 5 comments
Open

Select component based on matching criteria function #195

ChrisLane opened this issue Apr 26, 2023 · 5 comments

Comments

@ChrisLane
Copy link

For the example JSX below

<TodoApp className="todo-app">
    <div>
        <TodoList>
            <TodoItem priority="High">Item 1</TodoItem>
            <TodoItem priority="Low">Item 2</TodoItem>
        </TodoList>
        <TodoList>
            <TodoItem priority="Medium">Item 1</TodoItem>
        </TodoList>
    </div>
</TodoApp>

If I want to make some assertions on a TodoList component that contains a TodoItem with priority="Medium", I would have to filter TodoList components based on the values in .child() or .findReact("TodoItem").withProps({priority: "Medium"})

I think it would be cleaner if if could instead select a component based on whether a function returns true.
For example:

const mySelector = ReactSelector("TodoList").matches(selector => selector.findReact("TodoItem").withProps({priority: "Medium"}));

Would this be a possible improvement that could be incorporated into the project?

@miherlosev
Copy link

Hi @ChrisLane,

Thank you for sharing this idea with us.

Copy link

This issue has been automatically marked as stale because it has not had any activity for a long period. It will be closed and archived if no further activity occurs. However, we may return to this issue in the future. If it still affects you or you have any additional information regarding it, please leave a comment and we will keep it open.

@ChrisLane
Copy link
Author

Bump

Copy link

This issue has been automatically marked as stale because it has not had any activity for a long period. It will be closed and archived if no further activity occurs. However, we may return to this issue in the future. If it still affects you or you have any additional information regarding it, please leave a comment and we will keep it open.

@ChrisLane
Copy link
Author

Bump

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants