Skip to content

Instantly share code, notes, and snippets.

@mrcthms
Created February 5, 2019 13:11
Show Gist options
  • Save mrcthms/b99298979eb3b9b2eedc67fba97c30be to your computer and use it in GitHub Desktop.
Save mrcthms/b99298979eb3b9b2eedc67fba97c30be to your computer and use it in GitHub Desktop.
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