Skip to content

[BREAKING]: Deprecate waitForElement #416

@kentcdodds

Description

@kentcdodds

Just a thought. What if we remove waitForElement in favor of find* queries?

For history: waitForElement was created before find* queries. Now that we have find* queries, I don't see much of a reason to continue to support it. Most of the time you can use a query, and in the rare situation where you can't use a query to get an element, then you can use wait:

const element = await wait(() => {
  const el = container.querySelector('.blah')
  if (!el) throw new Error('cannot find element with .blah')
  return el
})

It's a bit of boilerplate, but keep in mind that this is not something people should be doing very often nor is it something we want to encourage people to do.

I believe that some of the usages of waitForElement could be codemodable, but not all of it.

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    BREAKING CHANGEThis change will require a major version bumpneeds discussionWe need to discuss this to come up with a good solutionreleased

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions