Skip to content

Commit b08ac47

Browse files
committed
improve module
1 parent ced78c9 commit b08ac47

1 file changed

Lines changed: 19 additions & 13 deletions

File tree

module/index.js

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,41 @@ export const ContextDevTool = ({ id, context: Context, displayName }) => {
1414

1515
return (
1616
<Context.Consumer>
17-
{values => {
18-
if (typeof window !== 'undefined' && window._REACT_CONTEXT_DEVTOOL) {
17+
{(values) => {
18+
if (typeof window !== "undefined" && window._REACT_CONTEXT_DEVTOOL) {
1919
window._REACT_CONTEXT_DEVTOOL({ id, displayName, values });
2020
}
2121
return null;
2222
}}
2323
</Context.Consumer>
2424
);
25-
}
25+
};
2626

2727
export const debugContextDevtool = (container, options) => {
2828
debugOptions = { ...debugOptions, ...options };
2929

3030
if (
31-
debugOptions.disable ||
32-
debugOptions.disableAutoMode ||
33-
typeof window === 'undefined' ||
34-
(!debugOptions.debugReducer && !debugOptions.debugContext)
31+
debugOptions.disable ||
32+
debugOptions.disableAutoMode ||
33+
typeof window === "undefined" ||
34+
(!debugOptions.debugReducer && !debugOptions.debugContext)
3535
) {
36-
return false;
36+
return false;
3737
}
3838

3939
const hook = window.__REACT_CONTEXT_DEVTOOL_GLOBAL_HOOK;
4040

41-
if (debugOptions.debugReducer) {
42-
hook.helpers.loadHookHelper().then(() => {
41+
if (hook && hook.debugFiber) {
42+
if (
43+
hook.helpers &&
44+
hook.helpers.loadHookHelper &&
45+
debugOptions.debugReducer
46+
) {
47+
hook.helpers.loadHookHelper().then(() => {
48+
hook.debugFiber(container, options);
49+
});
50+
} else {
4351
hook.debugFiber(container, options);
44-
});
45-
} else {
46-
hook.debugFiber(container, options);
52+
}
4753
}
4854
};

0 commit comments

Comments
 (0)