@dxos/web-context-react 0.8.4-main.40e3dcdf1b → 0.8.4-main.422d1c7879
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/web-context-react",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.422d1c7879",
|
|
4
4
|
"description": "React integration with web context protocol",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -21,15 +21,12 @@
|
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
23
|
"types": "dist/types/src/index.d.ts",
|
|
24
|
-
"typesVersions": {
|
|
25
|
-
"*": {}
|
|
26
|
-
},
|
|
27
24
|
"files": [
|
|
28
25
|
"dist",
|
|
29
26
|
"src"
|
|
30
27
|
],
|
|
31
28
|
"dependencies": {
|
|
32
|
-
"@dxos/web-context": "0.8.4-main.
|
|
29
|
+
"@dxos/web-context": "0.8.4-main.422d1c7879"
|
|
33
30
|
},
|
|
34
31
|
"devDependencies": {
|
|
35
32
|
"@testing-library/react": "^16.3.0",
|
package/src/consumer.test.tsx
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// @vitest-environment jsdom
|
|
6
6
|
|
|
7
7
|
import { act, cleanup, render, screen } from '@testing-library/react';
|
|
8
|
-
import React from 'react';
|
|
8
|
+
import React, { ReactNode, useEffect, useRef, useState } from 'react';
|
|
9
9
|
import { afterEach, describe, expect, test } from 'vitest';
|
|
10
10
|
|
|
11
11
|
import { CONTEXT_REQUEST_EVENT, createContext } from '@dxos/web-context';
|
|
@@ -37,7 +37,7 @@ describe('useWebComponentContext', () => {
|
|
|
37
37
|
|
|
38
38
|
test('consumes context from updates (subscription)', async () => {
|
|
39
39
|
const Container = () => {
|
|
40
|
-
const [val, setVal] =
|
|
40
|
+
const [val, setVal] = useState('initial');
|
|
41
41
|
return (
|
|
42
42
|
<>
|
|
43
43
|
<button onClick={() => setVal('updated')}>Update</button>
|
|
@@ -59,9 +59,9 @@ describe('useWebComponentContext', () => {
|
|
|
59
59
|
});
|
|
60
60
|
|
|
61
61
|
test('consumes context from DOM parent (outside React tree)', () => {
|
|
62
|
-
const Wrapper = ({ children }: { children:
|
|
63
|
-
const ref =
|
|
64
|
-
|
|
62
|
+
const Wrapper = ({ children }: { children: ReactNode }) => {
|
|
63
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
64
|
+
useEffect(() => {
|
|
65
65
|
const handler = (e: Event) => {
|
|
66
66
|
const event = e as any;
|
|
67
67
|
if (event.context === ctx) {
|