Created
February 5, 2019 13:11
-
-
Save mrcthms/b99298979eb3b9b2eedc67fba97c30be 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
import React, { Fragment } from 'react' | |
import { Modal, Button } from 'invision-helios' | |
class MyComponent extends React.Component { | |
state = { | |
open: false | |
} | |
handleClick = () => { | |
this.setState(prev => ({ | |
open: !prev.open | |
})) | |
} | |
handleRequestClose = () => { | |
// gets fired when the modal closes, so should be only used for async side effects such as analytics tracking, etc. | |
analytics.track('Modal closed') | |
} | |
render() { | |
return ( | |
<Fragment> | |
<Button order="primary" onClick={this.handleClick}>Click me</Button> | |
<Modal open={this.state.open} onRequestClose={this.handleRequestClose}> | |
<div>I am the modal | |
</Modal> | |
</Fragment> | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment