main
Last change
on this file since 0c6b92a was 0c6b92a, checked in by stefan toskovski <stefantoska84@…>, 5 weeks ago |
Pred finalna verzija
|
-
Property mode
set to
100644
|
File size:
334 bytes
|
Rev | Line | |
---|
[0c6b92a] | 1 | import {useEffect} from "react";
|
---|
| 2 |
|
---|
| 3 | export function useModalEvent(openModalHandler,eventName){
|
---|
| 4 | useEffect(() => {
|
---|
| 5 |
|
---|
| 6 | if(eventName == null) return;
|
---|
| 7 |
|
---|
| 8 | window.addEventListener(eventName, openModalHandler);
|
---|
| 9 |
|
---|
| 10 | return () => {
|
---|
| 11 | window.removeEventListener(eventName, openModalHandler);
|
---|
| 12 | };
|
---|
| 13 | }, []);
|
---|
| 14 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.