@solim/react-queryselector
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

react-queryselector

Query react components in the same way query html tag with querySelector, useful for:

  • Testing, stop using data-testid
  • Automation
  • Chrome extension for hacking the dom

Usage

import reactQuerySelector from '@solim/react-queryselector'

// Setup the app

const MyButton = () => <button type="button">Click me</button>

const App = () => (
  <div>
    Hello world
    <MyButton/>
  </div>
)

render(<App/>, document.getElementById('app'))

// Use reactQuerySelector to query component

reactQuerySelector('MyButton')
reactQuerySelector('App')
reactQuerySelector('button[type="button"]')

Readme

Keywords

none

Package Sidebar

Install

npm i @solim/react-queryselector

Weekly Downloads

1

Version

1.0.5

License

none

Unpacked Size

19.2 kB

Total Files

5

Last publish

Collaborators

  • solim