Skip to content

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
trueadm committed Aug 5, 2020
1 parent da2868d commit 05a69b4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2220,13 +2220,10 @@ describe('ReactDOMServerPartialHydration', () => {

function Button() {
const ref = React.useRef(null);
const effect = () => {
return setClick(ref.current, onEvent);
};
if (isServerRendering) {
React.useEffect(effect);
} else {
React.useLayoutEffect(effect);
if (!isServerRendering) {
React.useLayoutEffect(() => {
return setClick(ref.current, onEvent);
});
}
return <a ref={ref}>Click me</a>;
}
Expand Down Expand Up @@ -2379,13 +2376,10 @@ describe('ReactDOMServerPartialHydration', () => {
function Button() {
const ref = React.useRef(null);

const effect = () => {
return setClick(ref.current, onEvent);
};
if (isServerRendering) {
React.useEffect(effect);
} else {
React.useLayoutEffect(effect);
if (!isServerRendering) {
React.useLayoutEffect(() => {
return setClick(ref.current, onEvent);
});
}

return <a ref={ref}>Click me</a>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,15 +354,12 @@ describe('ReactDOMServerSelectiveHydration', () => {
function Child({text}) {
const ref = React.useRef(null);
Scheduler.unstable_yieldValue(text);
const effect = () => {
return setClick(ref.current, () => {
Scheduler.unstable_yieldValue('Clicked ' + text);
if (!isServerRendering) {
React.useLayoutEffect(() => {
return setClick(ref.current, () => {
Scheduler.unstable_yieldValue('Clicked ' + text);
});
});
};
if (isServerRendering) {
React.useEffect(effect);
} else {
React.useLayoutEffect(effect);
}

return <span ref={ref}>{text}</span>;
Expand Down Expand Up @@ -433,15 +430,12 @@ describe('ReactDOMServerSelectiveHydration', () => {
}
Scheduler.unstable_yieldValue(text);

const effect = () => {
return setClick(ref.current, () => {
Scheduler.unstable_yieldValue('Clicked ' + text);
if (!isServerRendering) {
React.useLayoutEffect(() => {
return setClick(ref.current, () => {
Scheduler.unstable_yieldValue('Clicked ' + text);
});
});
};
if (isServerRendering) {
React.useEffect(effect);
} else {
React.useLayoutEffect(effect);
}

return <span ref={ref}>{text}</span>;
Expand Down Expand Up @@ -524,15 +518,12 @@ describe('ReactDOMServerSelectiveHydration', () => {
}
Scheduler.unstable_yieldValue(text);

const effect = () => {
return setClick(ref.current, () => {
Scheduler.unstable_yieldValue('Clicked ' + text);
if (!isServerRendering) {
React.useLayoutEffect(() => {
return setClick(ref.current, () => {
Scheduler.unstable_yieldValue('Clicked ' + text);
});
});
};
if (isServerRendering) {
React.useEffect(effect);
} else {
React.useLayoutEffect(effect);
}
return <span ref={ref}>{text}</span>;
}
Expand Down

0 comments on commit 05a69b4

Please sign in to comment.