Skip to content

Commit

Permalink
fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
Eszter Hofmann committed Aug 30, 2019
1 parent a1d8745 commit d1e3a23
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/components/TwoPaneView/TwoPaneView.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,6 @@ const TwoPaneView = props => {
const leftRef = React.createRef();
const blockRef = React.createRef();

React.useLayoutEffect(() => {
window.addEventListener('scroll', handleScroll);
return () => window.removeEventListener('scroll', handleScroll);
});

React.useLayoutEffect(() => {
window.addEventListener('resize', handleResize);
return () => window.removeEventListener('resize', handleResize);
});

const handleScroll = (e, leftEl = leftRef.current) => {
const leftDimensions = leftEl.getBoundingClientRect();
const top = leftDimensions.top > 0 ? 0 : -leftDimensions.top;
Expand Down Expand Up @@ -62,6 +52,16 @@ const TwoPaneView = props => {
handleScroll(e, leftEl);
};

React.useLayoutEffect(() => {
window.addEventListener('scroll', handleScroll);
return () => window.removeEventListener('scroll', handleScroll);
});

React.useLayoutEffect(() => {
window.addEventListener('resize', handleResize);
return () => window.removeEventListener('resize', handleResize);
});

return (
<BlockWidthRestrictor {...rest} ref={blockRef} {...block(props)}>
{React.Children.map(children, child => {
Expand Down Expand Up @@ -106,4 +106,8 @@ TwoPaneView.propTypes = {
},
};

TwoPaneView.defaultProps = {
children: null,
};

export default TwoPaneView;

0 comments on commit d1e3a23

Please sign in to comment.