Skip to content

Commit

Permalink
Add noop useDebugValue hook to partial/server renderer (#14597)
Browse files Browse the repository at this point in the history
  • Loading branch information
bvaughn committed Jan 15, 2019
1 parent 0ca628b commit 153a0b5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ let useMemo;
let useRef;
let useImperativeHandle;
let useLayoutEffect;
let useDebugValue;
let forwardRef;
let yieldedValues;
let yieldValue;
Expand All @@ -48,6 +49,7 @@ function initModules() {
useCallback = React.useCallback;
useMemo = React.useMemo;
useRef = React.useRef;
useDebugValue = React.useDebugValue;
useImperativeHandle = React.useImperativeHandle;
useLayoutEffect = React.useLayoutEffect;
forwardRef = React.forwardRef;
Expand Down Expand Up @@ -658,4 +660,16 @@ describe('ReactDOMServerHooks', () => {
'Hooks can only be called inside the body of a function component.',
);
});

describe('useDebugValue', () => {
itRenders('is a noop', async render => {
function Counter(props) {
const debugValue = useDebugValue(123);
return <Text text={typeof debugValue} />;
}

const domNode = await render(<Counter />);
expect(domNode.textContent).toEqual('undefined');
});
});
});
2 changes: 2 additions & 0 deletions packages/react-dom/src/server/ReactPartialRendererHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,8 @@ export const Dispatcher = {
useImperativeHandle: noop,
// Effects are not run in the server environment.
useEffect: noop,
// Debugging effect
useDebugValue: noop,
};
export const DispatcherWithoutHooks = {
readContext,
Expand Down

0 comments on commit 153a0b5

Please sign in to comment.