shallowly
Version:
Shallowly: Modern shallow renderer for React 18+. Enzyme-compatible API, 2x faster, with TypeScript support.
13 lines (12 loc) • 505 B
TypeScript
/**
* Checks whether a React element matches the given selector. Supports:
* • function or class components
* • string selector of component/tag name
* • CSS-like .className and #id selectors for DOM elements
*
* @param {React.ReactNode} node Node to test.
* @param {string|Function} selector Selector.
* @returns {boolean} True if matches.
*/
export function matchesSelector(node: React.ReactNode, selector: string | Function): boolean;
import React from 'react';