Last active
March 6, 2019 09:44
-
-
Save ilyalesik/5f9d37024b3faed33910b0f847d09297 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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