Skip to content

Commit

Permalink
Added code snippet to use this using hooks and functional component
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinavrana committed Sep 22, 2020
1 parent f4878a0 commit 2ee9fad
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,30 @@ import sass file to your project
```scss
@import 'node_modules/react-modal-video/scss/modal-video.scss';
```
### Functional Implementation with Hooks

```jsx
import React,{useState} from 'react'
import ReactDOM from 'react-dom'
import ModalVideo from 'react-modal-video'

const App = () => {

const [isOpen, setOpen] = useState(false)

return (
<ModalVideo channel='youtube' autoplay isOpen={isOpen} videoId="L61p2uyiMSo" onClose={() => setOpen(false)} />

<button className="btn-primary" onClick={()=> setOpen(true)}>VIEW DEMO</button>
)
}

ReactDOM.render(
<App />,
document.getElementById('root')
)
```
### Class Implementation
change "isOpen" property to open and close the modal-video

```jsx
Expand Down

0 comments on commit 2ee9fad

Please sign in to comment.