-
-
Save hungqcao/571fa6dfe0522847b182a228e4d852af to your computer and use it in GitHub Desktop.
Draggable React Bootstrap modal
This file contains 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, { Component } from "react"; | |
import Modal from "react-bootstrap/Modal"; | |
import Draggable from 'react-draggable'; | |
import ModalDialog from 'react-bootstrap/ModalDialog'; | |
class DraggableModalDialog extends React.Component { | |
render() { | |
return <Draggable handle=".modal-title"><ModalDialog {...this.props} /></Draggable> | |
} | |
} | |
export default class BSModal extends Component { | |
render() { | |
return ( | |
<Modal | |
dialogAs={DraggableModalDialog} | |
show={this.props.show} | |
onHide={this.props.close}> | |
<Modal.Header> | |
<Modal.Title>{this.props.title}</Modal.Title> | |
</Modal.Header> | |
<Modal.Body> | |
{this.props.children} | |
</Modal.Body> | |
<Modal.Footer > | |
</Modal.Footer> | |
</Modal> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks. This worked for me.
dialogAs={DraggableModalDialog}
is important.