Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add noop useDebugValue hook to partial/server renderer #14597

Merged
merged 1 commit into from
Jan 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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