Skip to content

Instantly share code, notes, and snippets.

@ilyalesik
Last active March 6, 2019 09:44
Show Gist options
  • Select an option

  • Save ilyalesik/5f9d37024b3faed33910b0f847d09297 to your computer and use it in GitHub Desktop.

Select an option

Save ilyalesik/5f9d37024b3faed33910b0f847d09297 to your computer and use it in GitHub Desktop.
const Doctor = (props) => {
const [opened, setOpened] = useState(false);
return <div>
{props.expandable && <Arrow onClick={() => setOpened(!opened)} />}
</div>
}
const ExpandableDetector = (props) => {
const [expandable, setExpandable] = useState(false)
return <ReactResizeDetector handleHeight onResize={(height) => setExpandable(height > props.maxHeight)}>
{props.children(expandable)}
</ReactResizeDetector>
}
const Page = () => {
return <ExpandableDetector maxHeight={200}>
{expandable => <Doctor expandable={expandable} {...doctorProps} />}
</ExpandableDetector>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment