Skip to content

Commit e9cf80c

Browse files
committed
hadle custom objects
1 parent 50efb5c commit e9cf80c

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

example/csr/src/App.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,21 @@ const demo = {
1313
name: "Context Demo",
1414
};
1515

16+
const ws = new WeakSet();
17+
const foo = {};
18+
19+
ws.add(foo);
20+
21+
let myMap = new Map()
22+
myMap.set("s", 'not a number')
23+
24+
const valuesToTest = {
25+
f: new Set([1,2, 3,3]),
26+
g: ws,
27+
h: myMap,
28+
i: ws,
29+
}
30+
1631
const Test = () => {
1732
const [counter3, setCounter3] = React.useState(0);
1833
const [counter4, setCounter4] = React.useState(0);
@@ -52,7 +67,7 @@ class Test2 extends React.Component {
5267
// const { id } = this.context;
5368

5469
return (
55-
<MyContext2.Provider value={{ id: counter5, b: "world" }}>
70+
<MyContext2.Provider value={{ id: counter5, b: "world", ...valuesToTest }}>
5671
<button onClick={() => this.setState({ counter5: counter5 + 1 })}>
5772
Click 5 Me {counter5} {id}
5873
</button>

packages/devtool-extenstion/extension/core/injectGlobalHook.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,18 @@ function injectHelpers(target) {
8585
if (isHTMLElement(v)) {
8686
return `<${v.tagName}> HTMLElemet`;
8787
}
88+
if (v instanceof Set) {
89+
return `Set [${Array.from(v).toString()}]`;
90+
}
91+
if (v instanceof Map) {
92+
return `Map [${Array.from(v).toString()}]`;
93+
}
94+
if (v instanceof WeakSet) {
95+
return `WeekSet []`;
96+
}
97+
if (v instanceof WeakMap) {
98+
return `WeakMap {}`;
99+
}
88100
return v;
89101
});
90102
};

0 commit comments

Comments
 (0)