react-component-instance 0.0.7 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -11,17 +11,28 @@ import getInstance from 'react-component-instance'
11
11
  **Note** that for use with _Testing Library_ import from `react-component-instance/container`
12
12
 
13
13
  ```javascript
14
- import getInstance from 'react-component-instance/container'
15
-
16
14
  import {
17
15
  render
18
16
  } from '@testing-library/react'
19
17
 
20
- const {
21
- container
22
- } = render(
23
- <Component />
24
- )
18
+ import getInstance from 'react-component-instance/container'
25
19
 
26
- const instance = getInstance(container)
20
+ describe('`getInstance`', () => {
21
+ class Component extends React.Component {
22
+ render () {
23
+ return <div />
24
+ }
25
+ }
26
+
27
+ it('gets the instance', () => {
28
+ const {
29
+ container
30
+ } = render(
31
+ <Component />
32
+ )
33
+
34
+ expect(getInstance(container))
35
+ .toBeInstanceOf(Component)
36
+ })
37
+ })
27
38
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-component-instance",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "Get a React class component instance from its DOM Element",
5
5
  "keywords": [
6
6
  "react",
@@ -41,7 +41,7 @@
41
41
  "@testing-library/react": "^16.2.0",
42
42
  "@types/debug": "^4.1.12",
43
43
  "@types/jest": "^29.5.14",
44
- "@types/react": "^19.0.11",
44
+ "@types/react": "^19.0.12",
45
45
  "core-js": "^3.41.0",
46
46
  "eslint": "^9.22.0",
47
47
  "eslint-plugin-react": "^7.37.4",
@@ -1,4 +1,5 @@
1
1
  /**
2
+ * @typedef {import('@testing-library/react').RenderResult} RenderType
2
3
  * @typedef {ReactComponentInstanceTypes.FiberRootNode} FiberRootNode
3
4
  */
4
5
 
@@ -21,7 +22,7 @@ export function getContainerFiberNodeFrom (container) {
21
22
  }
22
23
 
23
24
  /**
24
- * @param {{ container: { firstElementChild: Element | null } }} component
25
+ * @param {RenderType} component
25
26
  * @returns {Element | null}
26
27
  */
27
28
  export function getComponentElement ({
package/src/index.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  /**
2
+ * @typedef {import('@testing-library/react').RenderResult} RenderType
2
3
  * @typedef {ReactComponentInstanceTypes.FiberNode} FiberNode
3
4
  */
4
5
 
@@ -87,7 +88,7 @@ export function getChildFiberNodeFrom (element) {
87
88
  }
88
89
 
89
90
  /**
90
- * @param {{ container: { firstElementChild: Element | null } }} component
91
+ * @param {RenderType} component
91
92
  * @returns {Element | null}
92
93
  */
93
94
  export function getComponentElement ({
package/tsconfig.json DELETED
@@ -1,14 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "module": "NodeNext",
4
- "target": "ESNext",
5
- "allowJs": true,
6
- "checkJs": true,
7
- "noEmit": true,
8
- "strict": true,
9
- "jsx": "react"
10
- },
11
- "include": [
12
- "."
13
- ]
14
- }